Craig Longman wrote:
> i've been trying to figure out what happens to the request object when
> you import a file, but had no answers from the tomcat list, so i thought
> i'd try here.
> 
> when you include a file via c:insert that actually maps to another
> servlet, it appears that the request object (in tomcat 4.1.10 at least)
> doesn't reflect any of the actual request being delivered.  i'm a little
> confused as to what i can do now.
> 
> the specifics are that i have a servlet that i want to call with a url
> indicating a specific file that i want retrieved.  this would be most
> useful if it could be called directly, or imported into another jsp
> file.  the url would look like:
> 
>  /mapper/file-to-get
> 
> the file-to-get would be retrieved by the servlet and then it looks up
> the correct file and processes it.
> 
> however, when this url is invoked via a <c:import url="/mapper/file">,
> all of the information retrievable via the request object refer to the
> 'wrapping' request, to the jsp page contains the c:import.  the
> parameters passed are available, but don't show up in the query string
> (because the query string is for the containing jsp page).
> 
> is this the correct behaviour?  i can't find anything definitive in the
> spec, so i'm not sure if this is a bug (it seems like 4.1.10 has a few)
> or the expected behaviour.  and if it is expected, then is there _any_
> of retrieving 'file-to-get' part if the servlet is invoked via an
> import?

The JSTL <c:import> action behaves like a RequestDispatcher.include()
when you import a resource in the same container. This means (as defined
by the Servlet spec) that the URI for the request is the URI for the
_including_ resource (the JSP page in this case), so the behavior you
see is correct.

You do have access to the URI info that was used to include the resource
through request attributes. This is from the Servlet spec:

   SRV.8.3.1 Included Request Parameters
   Except for servlets obtained by using the getNamedDispatcher method,
   a servlet being used from within an include has access to the path by
   which it was invoked. The following request attributes are set:

     javax.servlet.include.request_uri
     javax.servlet.include.context_path
     javax.servlet.include.servlet_path
     javax.servlet.include.path_info
     javax.servlet.include.query_string

   These attributes are accessible from the included servlet via the
   getAttribute method on the request object.

Hans
-- 
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.com
JavaServer Pages        http://TheJSPBook.com


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

Reply via email to