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

request object from session id

 
Shruthi Sam
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a method implemented which has the argument of session id. In the same method, is it possible to get the request object. The only input am having is session id. Please provide your suggestions.

Thanks,
Shruthi
 
Ed Ward
Ranch Hand
Posts: 147
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The HttpServletRequest has a much shorter scope than HttpSession, so even if you could get a request object from the session, how would you know if it is the one you needed unless your application or the specification implemented some mechanism to persist requst objects; which presents a whole nuther set of issues.

If you have the session id, then somewhere along the line you must have had access to th HttpServletRequest, so why not just pass it (or some other transport object) to your method and get the session id from the object from within your method? Either that or implement a method which can return what you need from the request and call if from your first method;
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Ed Ward. If you need you can put the object inside the session and you can get it back by request.getSession().getAttribute

Why would you need the session id?
 
Shruthi Sam
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much Edward and Hebert.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic