In HTTP terms, you are asking for the "referer" page -- the one that contained
a link that pointed at the current servlet. To retrieve that, just say:
String referer = req.getHeader("Referer");
and it will be there. This will return NULL, however, if someone had
bookmarked the servlet URL and then just executed it from their bookmark (or
just typed the servlet URL into their browser), so your code needs to watch
out for a NULL return valuve here. Perhaps you could go to a default JSP page
in that case.
Craig McClanahan
-Beheshti, Reza" wrote:
> Thanks to all of you who responded, but I still can not get to the original
> page URL!!!
> I tried both HttpUtils.getRequestURL() and req.getRequestURI() from the
> servlet and BOTH of them just return the URL for the servlet NOT the page
> that the servlet was called from.
>
> Here is an example of what I need to do:
>
> If I call my servlet (Say www.xxx.com/servlet/MyServlet
> <http://www.xxx.com/servlet/MyServlet> ) from www.xxx.com/page1.jsp
> <http://www.xxx.com/page1.jsp> I need to be able to return to
> www.xxx.com/page1.jsp <http://www.xxx.com/page1.jsp> after I am done my
> processing in the servlet. Since several different URLs can call the same
> process in servlet, I need to be able to return to the originating page.
> All the methods that I have tried so far, including the above mentioned
> ones, ALWAYS return the URL for the servlet (i.e.
> www.xxx.com/servlet/MyServlet <http://www.xxx.com/servlet/MyServlet> )
> instead of the originating .jsp page that I really need.
>
> I though about passing a parameter to the Servelt as to where to return to,
> but I was hoping that there is a way to find out where the originating
> .jsp's URL is in the servlet that receives the request.
>
> Any other thoughts?
>
> Thanks again,
> Reza
>
> -----Original Message-----
> From: Beheshti, Reza
> Sent: Wednesday, June 09, 1999 3:04 PM
> To: 'JSP List'
> Subject: How do you send them back to where they came from?
>
> Hi,
> I am relatively new to JSP and Servlet, so forgive me if this is a trivial
> question.
> I dogged thru the servelt API and did not find anything in "req" object
> where I can figure out the URL of the req.
> I need to be able to (in the servelet) figure out the origin URL of a
> request, so after I process the request in the servlet, I can send it
> back/redirect it to the same exact page/URL that it came from.
>
> Thanks,
> Reza
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff JSP-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".