Solved

Checking to see if the session is valid and not NULL

Posted on 2011-09-28
6
197 Views
Last Modified: 2012-05-12
How can I check to make sure that my session is valid and not null?
0
Comment
Question by:jkteater
  • 2
  • 2
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 36717968
Something like
HttpSession s = req.getSession(false);
boolean validSession = (s != null);

Open in new window

0
 

Author Comment

by:jkteater
ID: 36718318
can you print out anything related to the session?

HttpSession s = req.getSession(false);

System.out.println( s.toString());
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36718347
You cann printa arrayy of names:
String [] ss = session.getValueNames();
for(String s: ss)System.out.println(s);

Open in new window

0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 50 total points
ID: 36718405
You may try tp print s.toString() but chances are you'll get some cryptic like Session@...(some numbers or something).
 And if you print list of stored filed names - that would be meaningful:

HttpSession session = req.getSession(false);
if(session != null){
String [] ss = session.getValueNames();
for(String s: ss)System.out.println(s);
}

Open in new window

0
 

Author Comment

by:jkteater
ID: 36718427
Thanks to Both of you
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36814180
:)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 58
pairstar challenge 2 42
countHi2 challenge 7 44
Problem to start Neon 20 54
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now