I want to check if a certain key/value pair has been set.
How do I check if a an entry with key named "keyName" exists. Sample code or a pointer to an example would be appreciated.
I want to check if a certain key/value pair has been set.
How do I check if a an entry with key named "keyName" exists. Sample code or a pointer to an example would be appreciated.
Heres a simple introductory tutorial to JSP Sessions
In essence you should just need to check that session.getAttribute("keyName")
is not null.
You can set/get attributes (key/value) in a HttpSession object. An example: http://www.exampledepot.com/egs/javax.servlet/State.html
If you want to differ between "not set" and null
, step through session.getAttributeNames()
and search your key name.