Getting session

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2007
Posts: 59
Reputation: Chaster is an unknown quantity at this point 
Solved Threads: 3
Chaster Chaster is offline Offline
Junior Poster in Training

Getting session

 
0
  #1
Oct 30th, 2008
Hello,

How can I get a reference to a session? I have a page, which forms a query string, and in another page I would like to display the attributes of it. I don't want to introduce scriplets, so I am trying to do this in a pure Java file, where request is not an implicit-object. When I was using Struts, I was able to get that reference by HttpSession session = ServletActionContext.getRequest().getSession(); Can I do something similar without Struts? I tried to google it, but nothing helpful.

Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 7,649
Reputation: ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of ~s.o.s~ has much to be proud of 
Solved Threads: 474
Super Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Failure as a human

Re: Getting session

 
0
  #2
Oct 31st, 2008
You don't need `session' to display the request parameters; just use request.getParameter("parameterName") inside your servlets' doGet / doPost and you should be good to go.

BTW, you can get a reference to the `session' using the HttpServletRequest ; read the API docs.
I don't accept change; I don't deserve to live.

Jo Tujhe Jagaaye, Nindein Teri Udaaye Khwaab Hai Sachcha Wahi.
Nindon Mein Jo Aaye Jise To Bhul Jaaye Khawab Woh Sachcha Nahi.
Khwaab Ko Raag De, Nind Ko Aag De
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 847 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC