tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mike W-M" <>
Subject Re: JSP to Servlet to JSP pathing issue. Relative PathingPlease help.
Date Tue, 17 Dec 2002 15:43:56 GMT
True (and I missed that that was the whole point of your exercise) but
redirecting is the (only) way to get the browser's URL to change.

If you think about it, you're basically saying that you want two different
URLs (one to the servlet and one to the jsp), when displayed in the browser,
to mean the same thing - which just isn't going to work.

Two possible solutions:
a) The ugly but quicker one:   code the absolute URL in the jsp's form's
action attribute.
b) The elegant one:  Don't link to the jsp page at all.  Always link to the
servlet, then make the servlet check for the existence of parameters.  If
your parameters exist then it was a form submission, so do what ever you do
now and then forward() to the jsp.  (This leaves the URL the same in the
browser and doesn't lose the request-info.)  If parameters don't exist, then
just forward() to the jsp page (without doing any processing).  It'll
presumably behave like it does now when you request it directly.  However,
the browser's URL will still have the servlet's URL - and you can code all
the paths relative to that.


----- Original Message -----
From: "Jason Johnston" <>
To: <>
Sent: Tuesday, December 17, 2002 3:25 PM
Subject: Re: JSP to Servlet to JSP pathing issue. Relative PathingPlease

The redirecting doesn't seem to work.  That tells the browser client to
initiate a new request and all the
information that I placed in the request object is gone, which
undermines the purpose of the form.

The forums have a lot on my problem, just no answers that have worked
for me.  Has anyone else ran into the issue of using a form in a JSP to
submit data to a Servlet, have that servlet return data to the very same

Thanks in advance.

>>> 12/16/02 12:53PM >>>
Thanks for the advice, I didn't know you could redirect. The javadoc
the RequestDispatcher only lists the forward and include methods.
try that.

The initial call to the servlet is actually being made by the client
browser via a form response.

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


----- Original Message -----
From: "Jason Johnston" <>
To: "<"Tomcat Users List"" <>
Sent: Monday, December 16, 2002 5:46 PM
Subject: JSP to Servlet to JSP pathing issue. Relative Pathing Please

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:


This then sends the form data to the

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


The original JSP comes up fine and has the results, but the path in
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.



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


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

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

View raw message