• 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

storing request object in session

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i was trying to store request object in session variable. but that session variable is empty on the next page. but i can access that variable in the page, where it is stored. is it not possible to store request object in session?
i was trying to access the request object in a frameset. is there anyway to pass request object to a particular frame?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
session.setAttribute("name",value);
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpSession session = request.getSession();
session.setAttribute("request", request);

won't work too well, you're getting recursive calls here.
HttpSession session = ((HttpRequest)session.getAttribute("request")).getSession();

Doesn't look healthy
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. Are you attempting to store the entire request object into the session or just certain attribute-value pairs into the session?

If its the former, why not consider iterating through your request object and store them into your session?

Hope I didn't misinterprete your question.
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, it's a really bad idea and I hope it doesn't work - if somehow it does, the behaviour would be indeterminate ie wierd and unpredictable.

As some pole have hinted, you're better moving the specific request-scope data to the session if you want to hold on to it, don't try to hold the request object, it represents something completely different.

Dave
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Storing the request object ANYWHERE is a bad idea. Request objects are managed by the servlet container and you MUST NOT try to hang on to one past the end of a single request. If you need to keep all the parameters try something like getParameterMap().
Bill
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic