How to verify that a session object contains a specific key / value record

I want to check if a specific key / value pair is installed.

How to check if a record exists with a key named "keyName". Sample code or a pointer to an example will be appreciated.

+3
source share
2 answers

If you want to distinguish between "not defined" and null, go through session.getAttributeNames()and search for the name of your key.

+4
source

Here is a simple introductory tutorial on JSP Sessions

In essence, you just need to verify that session.getAttribute("keyName")it is not null.

+1
source

Source: https://habr.com/ru/post/1721884/


All Articles