• 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

lose request object when using response.sendRedirect()

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
for redirecting a url i am using response.sendRedirect ,but in this case I lose the request object and can not retrieve the request object and request attributes on my resulting url.
kindly suggest what can i use to get thr request attributes.
thanks.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
you can use RequestDispatcher.forward method to forward request some other resource where request will be available in forwarded page.
Thanks
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you do a request.sendRedirect(), you are sending the response back to the client, and the client akes another request to fetch the redirect URL. Since this becomes a separate request, and the first request ends once the redirect is sent back to the client, that request object and and hence its attributes are lost.

to overcome this:
1. use the method described in the above post. use RequestDispatcher.forward or RequestDispatcher.include

2. if using redirect is necessary, u will have to send the request attributes manually as hidden form fields and retrieve them in the next servlet/JSP OR put the attributes in the session.
 
They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic