tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <>
Subject Re: Forward to JSP from Servlet
Date Fri, 16 May 2003 03:35:48 GMT
Nope, the problem is that you are confusing the h*ll out of the browser.
The browser has no knowledge at all that you've done a forward, so it will
request relative links for things like stylesheets and images against the
URL that it sent.  It doesn't know or care about the URL that you forwarded

You can stay with this design, but you'd have to make all of the references
to stylesheets and images absolute in your JSP page (e.g. <img
src="/myapp/images/cool.jpg"> instead of <img src="images/cool.jpg">).

"Daryl Handley" <> wrote in message
> Hi all,
> When I forward to a JSP from a servlet, my JSP page is unable to find the
> resources (stylesheets, images, ....)it needs to display the page
> The page comes up fine if I just type in the address of the JSP ...
> localhost/OnlineStore/jsp/index.jsp for example
> ... but if I forward to the page ....
> getsServletContext().getRequestDispatcher("/jsp/index.jsp").forward(req,
> res);
> ... it comes up with no stylesheets applied and none of my images are
> visible.
> I tried doing a res.sendRedirect and it worked fine (as I expected it
> I don't really want to use sendRedirect unless I have to since it has it's
> own problems.
> I'm assuming this has something to do with the servlet that is compiled
> the jsp assuming the resources are going to be somewhere different, but
> not really sure. I'm fairly new to Tomcat, but I used to do these kinds of
> forwards all the time using Websphere with no problem. Maybe there is some
> setting somewhere that I need to adjust ?
> Tomcat is v4.1.24
> Daryl

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message