• 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 values in session

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello guys..
I'm a newbie to Struts2.and now i'm creating a small application by using it.
In this, i want to add username into session whenever i do login. and whenever i click logout link i need to destroy the username in session.
so that i will check whether the session is containing username or not and after that i will provide authorization to view the pages.
My question is ..
how to set username in session ?
how to access it in jsp page..?
and how to remove it .?
please explain it with corresponding syntax...
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajaprabhu Aravindasamy wrote:
how to set username in session ?


1. create a new session upon successful authentication

2.and set user name;redirect to welcome page

*dont use jsp for this purpose

Rajaprabhu Aravindasamy wrote:
how to access it in jsp page..?


Use Expression Language
${sessionScope['userName']}

Rajaprabhu Aravindasamy wrote:
and how to remove it .?


invalidate existing session


or for removing particular attribute-userName


*dont use jsp for this purpose

 
Ranch Hand
Posts: 290
Debian Fedora Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to access session , implement SessionAware Interface in Your Action Class. In jsp use session or attr to access.
<s:property value="#attr.username"/>.
 
Rajaprabhu Aravindasamy
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you guys..
I'll try this and post the result soon..!
 
Live ordinary life in an extraordinary way. Details embedded in 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