How do I check that a session object contains a particular key/value entry
I want to check if a certain key/value pair has be开发者_如何学Goen 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.
If you want to differ between "not set" and null
, step through session.getAttributeNames()
and search your key name.
Heres a simple introductory tutorial to JSP Sessions
In essence you should just need to check that session.getAttribute("keyName")
is not null.
精彩评论