File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response.sendRedirect() x RequestDispatcher.forward

 
Vinicius Carvalho
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello there! As far as I know (and I bet I'm wrong

Redirect adds a Header to the response (I guess Location) and the browser then redirects the user to the new location right?
Also forward can be used only within the same context.

Now, I have a server running Jetty and need to redirect the user to a tomcat machine, but I need to add some headers and attributes to the request, how can I do that? With redirect it does not work, and with forward (well, not the same context...)

Best Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The request in which you are about to send a response containing the redirect header will go out of scope as soon as the response is dispatched.

So there really is no request to which to can add anything.

You can put query parameters on the redirect URL, which will be turned into request parameters when the browser initiates the redirected request, but that's about the extent of control that you have.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic