• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RequestDispatcher Forward Change url

 
Ranch Hand
Posts: 44
1
Android Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic