tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert James" <aja...@sdyn.com>
Subject Relative vs. absolute with getServletConfig().getServletContext() .getRequestDispatcher().forward(request,response) ... please help!
Date Tue, 27 Jun 2000 00:45:48 GMT


Hello, I am in need of some insight!

When issuing a forward from a servlet to a JSP as in the following:

     request.setAttribute(...);

getServletConfig().getServletContext().getRequestDispatcher("/dirb/foo.jsp").forward(request,response);

If the servlet was in a different directory than the JSP, the browser will get
confused and try to load relative links relative to the servlet, not relative to
 the JSP.
This is bad for us as servlets from different locations often point to the same
JSP.

Does anyone have an elegant solution to this?  We have thought of three but none
 are particularly nice.

1)  in the JSP, use a <base href="http://server/dirb">.  This way, no matter
where the request was directed to, relative links are relative to the JSP.
2)  make all links absolute
3)  never forward to a page in a different directory (this would basically mean
we have to put all of our files in the same directory...blah!)
4)  could issue a redirect, but that adds overhead to the end user (i.e. two
seperate HTTP connections, right?)

Any comments would be most graciously accepted!

...
Kindest Regards,
Albert James



Mime
View raw message