Is there an HTTP header or other mechanism to force the browser to change the URL shown in the address bar (not redirect to a new URL to be loaded)? For example, you click a link with the URL "http://server/servlet?id=10&op=load", the servlet runs, and when it returns it tells the browser to display "http://server/servlet" as the URL for the page?
It's like client-side redirect since it changes the URL, but it's like server-side redirect (forward) in that it doesn't tell the browser to actually load another URL.
Here's the background:
I have a fairly simple servlet that displays a status screen with operation links when no parameters received. The operation links hit the same servlet, this time with parameters, that tell it what to do. I kept it all as one servlet since it's pretty simple.
Now, when an operation is performed, the work is done and the updated status screen is displayed. However, I want the URL in the browser to be the no-parameter status screen URL so they don't inadvertantly reload the page and perform the operation again. I used a client-side redirect to do this, and it works great.
However, now I'd like to display an error message on the status screen if the operation fails. Since it redirects to the status screen, the message must be stored in the session or elsewhere to save it. I can do this, but it seems far more work than is needed.
Does anyone know a simple solution like I outlined at the start? Thanks!
Sorry to ask but, did you tried to use POST instead of GET to remove your parameters and then, empty your doGet function in your servlet to make sure it will not be reprocess again?
Quite simple but had to ask...
F.<br />SCJP, SCJD, SCWCD, SCBCD<br /> <br />Failure is not an option... It comes with the software bundle.
Joined: Aug 07, 2003
Upon thinking about it a little more, it seems that using the HTTP session might work pretty well.
In fact, I suspect that I can't do as I originally hoped as it's probably a security risk to allow a web server to set the URL for the loaded page since the user will think that the browser actually loaded the page at the new URL, yet it didn't.
using HTTP forward calls is completely transparent to the client, he never knows it happens. There's no security risk as you can only forward to a relative URI (so one within the same domain). If your customers consider that a security risk, fire them and find other customers