tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Josh Knowles <josh.know...@worldwidepackets.com>
Subject RE: redirect from servlet to html breaks current location?
Date Wed, 18 Oct 2000 16:31:24 GMT
Try doing it this way:

RequestDispatcher dispatcher =
getServletContext().getRequestDispatcher("/foo.html");
dispatcher.forward(request, response);

Not sure if it will help but work a try

-----Original Message-----
From: Russell Freeman [mailto:RFreeman@globalrecall.com]
Sent: Wednesday, October 18, 2000 9:23 AM
To: 'tomcat-user@jakarta.apache.org'
Subject: RE: redirect from servlet to html breaks current location?


Hmm, but I thought specifying "/foo.html" (prefixed with the forward-slash)
with the redirection would have do this? (I would have expected "foo.html"
to be in the same place as the servlet).


-----Original Message-----
From: Josh Knowles [mailto:josh.knowles@worldwidepackets.com]
Sent: 18 October 2000 17:21
To: 'tomcat-user@jakarta.apache.org'
Subject: RE: redirect from servlet to html breaks current location?


What you are doing is forwarding the response on to the other page to get
processed but the servlet still has overall control (look at the url, it
should still read /servlet/something even after you get a new page).  So
what you need to do is make sure that you are using path names that are
relative to the servers root other wise it thinks that they are relative to
the servlet.

Hope this helps,

josh

-----Original Message-----
From: Russell Freeman [mailto:RFreeman@globalrecall.com]
Sent: Wednesday, October 18, 2000 9:12 AM
To: Tomcat-User (E-mail)
Subject: redirect from servlet to html breaks current location?


It seems that when I redirect from a servlet (within /appname/servlet) to
the web page "/foo.html" any relative links (e.g. otherpage.html) appear to
point to "/appname/servlet/otherpage.html", which is the wrong location
(should be /appname/otherpage.html)

My redirect code is like this:-

    getServletContext().getRequestDispatcher("/foo.html").forward(req,resp);

The documentation says that this will be relative to the current context
which I assumed would be /appname  - not /appname/servlet

Any ideas?

Thanks, 
Russ
Russ Freeman
SageMaker Inc
Delta 603, Swindon, UK, SN5 7XF
Tel: +44 (0) 1793 509 117 
mailto:russell.freeman@sagemaker.com

Mime
View raw message