This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

How to Clear unused Session Attributes

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i'm working on j2ee web application,
regarding unsed sessions we are getting lots of problem,
how to handle such kind problems in future.
suggestions & guidance are welcome.

Thanking you
Karthikeyan R
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What sort of problem?
 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And how is it that you intend to differentiate between used and unused attributes? If it is like, they're set before displaying a particular screen, then you can take care that after the screen has been displayed, you remove the attributes.
You can't arbitrarily decide at a particular point of a user's browsing session which all attributes are used/unused. Unless ofcourse you have a hardcoded list of attributes which define, before every servlet/JSP renders the response, all the possible attribute names that can exist, and remove all other attributes present.
[ May 01, 2008: Message edited by: Anirvan Majumdar ]
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
State your problem clearly.
 
Karthikeyan Ramaswamy
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, i tried this code it's working fine.

try
{
HttpSession session=request.getSession(false);
if(session!=null)
{
Enumeration attributeNames=session.getAttributeNames();
while(attributeNames.hasMoreElements())
{
String sAttribute=attributeNames.nextElement().toString();
if (!sAttribute.equals("org.apache.struts.action.LOCALE")
&& !sAttribute.equals("loginType")
&& !sAttribute.equals("LoginDetails")
&& !sAttribute.equals("SystemConfig")
&& !sAttribute.equals("RoleMenu")
&& !sAttribute.equals("reportContexPath")
&& !sAttribute.equals(GlobalNames.LOGIN_USER_SESSION_ID)
&& !sAttribute.equals("ecsClientId")
&& !sAttribute.equals("explorerClientId"))
{
//System.out.println(request.getRequestURL()+" Removing Session Attribute : "+sAttribute);
session.removeAttribute(sAttribute);
}
}
}
}catch(Exception e) { }
[ May 12, 2008: Message edited by: Karthikeyan Ramaswamy ]
 
What's that smell? Hey, sniff this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic