Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

remove particular data from session

 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

My question is:

there are two or more javabeans in the session,let's take two as example:userBean and newsBean.Sometimes,I want to find the newsBean and remove it from session without influence on userBean,is there any good idea ?

Thanks very much!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first place I'd look is the API document for the session class.
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, we can do it using embeded java scripts,like

<%... session.removeAttribute("beanName")... %>

However,is there similar things in pure jsp?

Thanks!
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried to use
:

${pageContext.session.removeAttribute('beanName')}

or

<c:set var="shishi" value="${pageContext.session.getAttribute('beanName')}" />

they never work.any ideas?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joshua Cloch:

<c:set var="shishi" value="${pageContext.session.getAttribute('beanName')}" />


Yes. Make an effort and learn valid EL syntax. Neither of the code snippets you posted is valid. You cannot make instance method calls with the EL.

You can do what you want with the JSTL and EL, but not in the way that you are doing it.

You will find links to the JSP and JSTL Specifications in my signature.
[ August 03, 2006: Message edited by: Bear Bibeault ]
 
Joshua Cloch
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much,but it could be better if anyone could show some sample code...
 
Praveen Babu
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This will remove the attribute named beanName from the session scope

Also to use an attribute from session use this,



You can now print the variable someVar using cut

Bye & Regards,
Praveen
[ August 04, 2006: Message edited by: praveen babu ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic