This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Karim Kiswarday
Ranch Hand
Posts: 50
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forward, but redirect to the URL you want to see in the browser's address bar.
 
Karim Kiswarday
Ranch Hand
Posts: 50
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64858
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to read this article and pay special attention to the P-R-G pattern.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic