aspose file tools*
The moose likes JSP and the fly likes remove particular data from session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "remove particular data from session" Watch "remove particular data from session" New topic
Author

remove particular data from session

Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
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!


truehh@hotmail.com
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

The first place I'd look is the API document for the session class.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joshua Cloch
Ranch Hand

Joined: Apr 27, 2006
Posts: 95
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

Joined: Apr 27, 2006
Posts: 95
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

Joined: Jan 10, 2002
Posts: 61224
    
  66

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

Joined: Apr 27, 2006
Posts: 95
Thanks very much,but it could be better if anyone could show some sample code...
Praveen Babu
Ranch Hand

Joined: Jul 30, 2006
Posts: 138


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 ]
 
Don't get me started about those stupid light bulbs.
 
subject: remove particular data from session