Java Mailing List Archive

http://www.junlu.com/

Google
Google
Mailing List
Home
Forum Home
JBoss - Java Application Server
Struts - A MVC web framework
Tomcat - JSP/Servlet container
iText - An open source PDF Java Library
JDOM - JDOM XML Parser
J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition
J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog
Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology
JSP - A mailing list about Java Server Pages specification and reference
Struts & Hibernate
Subjects
JSP editor plugin for eclipse ?
org apache jasper JasperException: Unable to compile class for JSP
Tomcat: Connection reset by peer: socket write error
Cannot retrieve definition for form bean null
Struts Tiles Tutorial (free Struts training)
Where do I download Tomcat 4 0 6?
Data Access Object (DAO) pattern, example DAO 's
Where to download Tomcat v 4 1 24 from?
Tomcat 5 0 16 Requested resource not available
Oracle Connection Pooling in 3 2 2
Servlet : Session invalidate
Servlet action is currently unavailable
Tomcat/Struts Unicode Encoding/Decoding problems
Tomcat and webapplication specific java library path
Running a Simple JMS Example
Mapping in workers2 properties
org apache jasper JasperException
Cannot find message resources under key org apache struts action
   MESSAGE
problem with html:text bean throwing exception
Cannot find message resources under key org apache struts action MESSAGE
invalid direct reference problem with solution
Tool for jsp debug Try Sysdeo Eclipse Plugin
Tomcat 5 Cannot load JDBC driver class 'null ' SQL state: null
weblogic ejbc
java properties file
Jboss 3 2 3 Coyote Can 't re
Tomcat 5, Apache2 and mod jk2 integration problem
JBoss example problem new to J2EE
url string for connecting jboss to oracle
Value attribute of <html:checkbox
javax servlet ServletException: BeanUtils populate
HTTP Status 404 The requested resource is not available
5 0 18: Windows XP Pro vs Windows 2000
 
ServletRequest 's path elements not updated by calls to getRequestDispatcher(

ServletRequest 's path elements not updated by calls to getRequestDispatcher(

2004-01-21       - By Mike Curwen

 Back
Reply:     1     2     3     4     5     6  

That's the request dispatcher. Images and CSS are all 'called' from the
client and have nothing to do with the dispatcher.

If you type in http://www.foo.com/target
then to the browser, the resource requested is 'target'
and your image and css links, if they're relative, are going to be
relative to www.foo.com

If, OTOH, you ask for http://www.foo.com/target/
then to your browser, you appear to be requesting a resouce in the
/target directory, and so images/css will be requested from there.

The simplest answer is:

replace "img=foo.gif"
with "img=/foo.gif"



> -- --Original Message-- --
> From: Alan Weissman [mailto:aweissman@(protected)]
> Sent: Wednesday, January 21, 2004 1:11 PM
> To: Tomcat Users List
> Subject: ServletRequest's path elements not updated by calls
> to getRequestDispatcher()
>
>
> Hi Everyone -
>
> I have a requirement to allow for URLs on a site of the
> format www.site.com/target where 'target' is not a real
> directory or servlet, but redirects to another page on the site.
>
> To handle this, I have developed a ServletFilter which takes
> the 'target' off the URL and attempts to do a server side
> forward to a servlet using the RequestDispatcher.  This is
> working for www.site.com/target.  I can get the
> RequestDispatcher from either the ServletRequest or the
> ServletContext and redirect to any target servlet with forward().  
>
> The problem arises where I try to handle www.site.com/target/
> (note the trailing slash).  In this case, the
> RequestDispatcher forwards to the target correctly HOWEVER,
> all subsequent HTTP GETs for images, css, etc, are being
> attempted on the wrong directory, /target/.  This seems to be
> because the ServletRequest doesn't seem to adjust its path
> elements accordingly.  For instance, if /target/ is supposed
> to redirect to target.jsp using forward("/target.jsp") the
> requests look like:
>
www.site.com/target.jsp
www.site.com/target/image.gif
www.site.com/target/style.css

Of course, /target was never a real directory to begin with :)  

Now, According to the API doc for RequestDispatcher:

"For a RequestDispatcher obtained via getRequestDispatcher(), the
ServletRequest object has its path elements and parameters adjusted to
match the path of the target resource. "

Does anyone have any experience with this issue?  Is this a bug?  Is
there a workaround?

Thanks so much,
Alan



-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)




©2008 junlu.com - Jax Systems, LLC, U.S.A.