• 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

Response.sendRedirect() x RequestDispatcher.forward

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
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
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic