Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Ranch Hand
Posts: 50
Eclipse IDE PHP Java
  • 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
 
Marshal
Posts: 25682
69
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 PHP Java
  • 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?
 
Marshal
Posts: 67420
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
Any sufficiently advanced technology will be used as a cat toy. And this tiny ad contains a very small cat:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic