File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Prevent 'null' in sessions..

 
Maky Chopra
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assume I have a jsp page with the following code :
<%
String name = (String) session.getValue("myName");
out.write(name)
%>
Now I execute it right out of the box without the myName session ever being created.. How can I prevent a nullpointerexception here ?
I've theoritically understood the true arguement but never got around to using it.
 
Andrew Shafer
Ranch Hand
Posts: 338
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Not sure if this is what you want, but one easy answer is:

 
Maky Chopra
Ranch Hand
Posts: 149
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats what I use.. actually the tertiary operator to populate name if the session is null..
What i was interested in was knowing if there is some kind of boolean true i can pass to getValue to automatically move " " or 0 to name if its null
guess not
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic