• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

remove particular data from session

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much,but it could be better if anyone could show some sample code...
 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 c:out

Bye & Regards,
Praveen
[ August 04, 2006: Message edited by: praveen babu ]
 
A feeble attempt to tell you about our stuff that makes us money
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic