Hi Kris,

Thanks for the reply. I have managed to get it worked out, but only be
looking even closer at the Tomcat source. It turns out to be the way
Tomcat wraps a request when using a RequestDispatcher. If the request
given to the dispatcher is a wrapper, Tomcat will look up the chain
until it finds the real original non-wrapped request, and wrap that.
That was a bit different than the behaviour I expected (I assumed it
would wrap my own wrapper, not look for the original request). I
modified my own wrapper's getParameter() method to call
super.getParameter() and now it works.

This behavour isn't specified in the servlet spec or the Tomcat docs...
Maybe it should be (would've saved me 5 hours of debugging). But I'll
bring that up on an appropriate list and not here. Thanks again for
replying.

Christian

-----Original Message-----
From: Kris Schneider [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 20, 2004 4:03 PM
To: Tag Libraries Users List
Subject: Re: c:import problem

Christian,

Not sure if you're still wrestling with this, but I just wanted to post
to say that I've been meaning to slap a little test app together as a
sanity check and I'll post back when I get the chance to code & run
it...

Quoting Christian Taylor <[EMAIL PROTECTED]>:

> Hi,
> 
> I'm new to this list, but far from a newbie when it comes to servlets,

> JSP, JSTL and Tomcat. I've spent hours trying to debug this problem, 
> searched the net and mailing lists and haven't been able to find a 
> solution. Here is my situation:
> 
> My application has many pages that use <c:import> to include a common 
> header. The header takes a "title" parameter. I've seen other people 
> doing this in the archives of this list. My code looks like this:
> 
> <c:import url="/include/header.jsp">
>   <c:param name="title" value="Title of the page"/> </c:import>
> 
> header.jsp uses the title for the <title> tag as well as to display to

> the user at the top of the page.
> 
> These pages can be accessed in two different ways:
> 
> 1) By a normal user of the application through a web browser
> 2) From a servlet that uses RequestDispatchers to capture some pages
>    to save as files that can be viewed offline.
> 
> The problem I'm having is with #2. The title parameter does NOT get 
> passed to header.jsp, and neither do request-scoped variables.
> 
> My "offline servlet" creates request and response wrappers to pass to 
> the RequestDispatcher's include() method. The wrapped request 
> overrides the relevent "parameter" methods (getParameter(), 
> getParameterMap(),
> etc.) and provides setter methods so I can pass parameters to the 
> pages to be "captured". It also defines a request-scoped variable 
> called _OfflineBackup which the pages can use to detect how they are 
> being accessed (some paths, etc. need to be different if the page is 
> to work offline).
> 
> My response wrapper is a typical "override getOutputStream() and
> getWriter() to capture the output" type of thing.
> 
> I've looked through the Tomcat and taglibs-standard sources and can't 
> find anything that would help. The code for the <c:import> tag appears

> to build a query string from the <c:param> tags and pass it as part of

> the URL to the RequestDispatcher it creates, but Tomcat's 
> ApplicationDispatcher implementation doesn't seem to do anything with 
> it, from what I can see in the source (but I'm not a Tomcat developer 
> and am not that familiar with the source). The parameters in the 
> wrapped request can be accessed from header.jsp, but not the actual 
> parameters passed to header.jsp using <c:param>.
> 
> This all leads me to my real question... why does my 'title' parameter

> work fine when I simply view the pages normally in a browser, but not 
> when I use a RequestDispatcher and my wrapped request/response? The 
> problem appears to be that Tomcat doesn't look at the parameters in 
> the path when getRequestDispatcher(path) is called, which makes me 
> wonder why the <c:param> tag ever works at all (but as I said, I'm not

> a Tomcat developer and have limited knowledge of the source so I could

> be wrong here, this is just what I've found from digging through the 
> sources). My wrappers seem to be working fine, and the import works 
> properly when viewing the page in a browser.
> 
> I hope I explained everything well enough and I apologize for this 
> being a bit long. I'm using Tomcat 5.0.28 and taglibs-standard 1.1.1. 
> This is a servlet 2.4/jsp 2.0 application. Thanks in advance to anyone

> who might be able to help me here!
> 
> Christian

--
Kris Schneider <mailto:[EMAIL PROTECTED]>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to