• Post Reply Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher Forward Change url  RSS feed

 
Kevin Olome
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)
 
Paul Clapham
Sheriff
Posts: 22721
43
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66264
151
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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!