Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

RequestDispatcher Forward Change url  RSS feed

 
Ranch Hand
Posts: 44
1
Android Firefox Browser Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
when I use the request dispatcher forward method, the resulting url always contains the name of the controller.

How can I remove it?

Steps (e.g. Register):
1. User clicks on register than hidden input field sends "event" to MvcController:

2. MvcController will call the process method on a subclass of EventHandlerBase.



3. After the forward the resulting Url is:
http://localhost:8080/MvcController

Is it possible to remove the last part of the URL? (/MvcController)
 
Sheriff
Posts: 23640
48
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Kevin Olome wrote:Hello,
when I use the request dispatcher forward method, the resulting url always contains the name of the controller.

How can I remove it?

Steps (e.g. Register):
1. User clicks on register than hidden input field sends "event" to MvcController:

2. MvcController will call the process method on a subclass of EventHandlerBase.



But it's not the forward() method which is producing that URL. That URL is the one coming from your <form> tag, which is why you see it at the top of your browser. The fact that a forward is happening on the server has no effect on that. And that's how browsers work, what you see at the top is the last URL which it sent a request to. That means that clicking "Refresh" on the browser will send the same request again.

So why do you want to subvert the normal way the browser works? What's wrong with showing the requested URL?
 
Author and ninkuma
Marshal
Posts: 66783
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:
So why do you want to subvert the normal way the browser works? What's wrong with showing the requested URL?


Because the POST can be accidentally repeated by the refresh button. It's best to not leave task controller URLs on the browser.

To solve this, read this article and pay particular attention to the PRG pattern.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!