You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jason Johnston <Ja...@epa.state.il.us> on 2002/12/16 19:53:01 UTC

Re: JSP to Servlet to JSP pathing issue. Relative Pathing Please help.

Thanks for the advice, I didn't know you could redirect. The javadoc on
the RequestDispatcher only lists the forward and include methods.  I'll
try that.
 
The initial call to the servlet is actually being made by the client
browser via a form response.


>>> mike@ward-murphy.co.uk 12/16/02 12:00PM >>>
If you want the path in the browser's address bar to change, I think
you
have to use a "redirect" rather than a "forward".  (I've read that even
then
it's not guaranteed to work (since it's browser-dependent), but it's
working
fine for me.  There's the disadvantage of an additional network
round-trip
that's not ideal, but I don't know of any other way.)
[Actually, I guess you're already redirecting from the original jsp
request
to the servlet.  If you changed that to "forward" then that'd probably
solve
you're problem without the additional round-trip....]

Mike.



----- Original Message -----
From: "Jason Johnston" <Ja...@epa.state.il.us>
To: "<"Tomcat Users List"" <to...@jakarta.apache.org>
Sent: Monday, December 16, 2002 5:46 PM
Subject: JSP to Servlet to JSP pathing issue. Relative Pathing Please
help.


I have a JSP that has a form that I want processed by a servlet.  The
servlet then places the results in the page context and redirects back
to the JSP.

Everything works fine on the first go, but the second time through the
path in the client's browser is no longer valid.

Initially, the path is:

http://localhost:8080/testgroup/lookup.jsp 

This then sends the form data to the
/testgroup/servlet/dolookup?<parameters>

The servlet executes and uses the request dispatcher to load the
original JSP.

                RequestDispatcher
rd=getServletContext().getRequestDispatcher("//lookup.jsp");
                rd.forward(request,response);

The original JSP comes up fine and has the results, but the path in
the
browser URL is still the servlet address.  Since the form sends to a
relative path, the second time you try to run, it doesn't work.


http://localhost:8080/testgroup/servlet/test.dolookup?epaid=J2466&search=id&

firstname=&lastname=

This seems to be a very simple relative pathing problem, but I've
tried
various solutions with no luck.  I'm sure someone else has run into
this
and found a solution.  If anyone has any insight, please help.

Thanks.



--
To unsubscribe, e-mail:  
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>