tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Barker" <wbar...@wilshire.com>
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
to.

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" <darylhandley72@yahoo.com> wrote in message
news:FNEJIOJHLIMDDBPLEEHBKEKDCAAA.darylhandley72@yahoo.com...
> 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
properly.
> 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
too).
> 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
from
> the jsp assuming the resources are going to be somewhere different, but
I'm
> 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
>
>
> TIA
> Daryl




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message