Link to home
Start Free TrialLog in
Avatar of mtiGirl
mtiGirl

asked on

How can I sendRedirect to where I came from without using cookies?

On a several different jsp pages I have the button that calls a servlet and processes data.  After the processing is complete I want to go back to the page where the button was hit.  The problem is I could have come from one of three pages. Is there anyway to determine this other than using a cookie or session variable?
SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dakyd
dakyd

Could you pass in the location of the page that calls the servlet to the servlet?  

In every page that has the button, make sure that document.location is included as part of the request.  Then the servlet can use this parameter as the page to return to.  Hope that helps.
Avatar of mtiGirl

ASKER

How do I make the document.location part of the request?

Thanks for the input!
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad we could help.  Thanks for the A. :^)

Cd&
Avatar of mtiGirl

ASKER

THANK YOU!
Avatar of mtiGirl

ASKER

How so I retrive the url where I came from using getHeaderField (I assume this is what you are talking about above) what name do I use as a parameter in order to return the url?  Or do I set it before I call the servlet?  I do not see a setHeaderField in the java api?  Any help would be appreciated.


--API for URLConnection

getHeaderField
public String getHeaderField(String name)
Returns the value of the named header field.
If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.


Parameters:
name - the name of a header field.
Returns:
the value of the named header field, or null if there is no such field in the header.
Assuming the header is using the HTTP standard then the name of the return address field is: REMOTE_ADDR

There is a list of the header variables here:

http://hoohoo.ncsa.uiuc.edu/cgi/env.html

Cd&


Avatar of mtiGirl

ASKER

Thanks a million -- that got it.
:^)

Just  a hint to help you using the site in the future.  Don't be too quick to accept an answer until you have gotten all the way through.  Some expert don't follow up as well as they should and may not continue the dialog after the question has been awarded.

Cd&
That'd be me COBOL's talking about ... sorry, was away from computer and couldn't get back to your question until now.  Sounds like you got what you needed, though.  Thanks for the A.
No I was not referring to you.  There are "top-experts" who are easy and obvious targets.  You don't have enough track record to be criticized yet. :^)

Welcome to the site... if you need any help just email me or any of the other page editors.

Cd&