aspose file tools*
The moose likes Servlets and the fly likes How to change the URL when the servlet forwards the page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to change the URL when the servlet forwards the page?" Watch "How to change the URL when the servlet forwards the page?" New topic
Author

How to change the URL when the servlet forwards the page?

Karim Kiswarday
Ranch Hand

Joined: Oct 01, 2010
Posts: 50

Hi friends,
do you know how to change the URL when the servlet forwards the page?

I have a HTML page (http://127.0.0.1:8080/test/index.html) with a form and it has the action set to "check".
When I submit the page the container (by DD) matches the action with the url-pattern and call the servlet.
At the end the servlet forwards at the proper JSP (A.jsp, B.jsp).

The problem is that any JSP is called, the URL in the browser doesn't change (it's http://127.0.0.1:8080/test/check).
How I can have http://127.0.0.1:8080/test/A or http://127.0.0.1:8080/test/B?

It's not very important but it can't be bookmarked.

Thanks,
Karim


No fun at the table, no fun in the sack.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18992
    
    8

Don't forward, but redirect to the URL you want to see in the browser's address bar.
Karim Kiswarday
Ranch Hand

Joined: Oct 01, 2010
Posts: 50

Paul Clapham wrote:Don't forward, but redirect to the URL you want to see in the browser's address bar.


But in this manner I lose the attributes put in the request.
If I don't want to use a session?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

You need to read this article and pay special attention to the P-R-G pattern.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change the URL when the servlet forwards the page?