Chapter 6. Session Management: Conversational state Flashcards

1
Q

How do you start a session with the client?

A

request.getSession() – Container handles all the rest.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you determine if the session you got is brand new for this client?

A

session.isNew();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How would you get ONLY a pre-existing session, AKA don’t create new but get it if it already exists?

A

request.getSession(false);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How would you terminate a session with a client?

A

session.invalidate();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How would you configure the session timeout in the Deployment Descriptor?

A

session-config, and under that session-timeout.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How would you configure the timeout for a sessinon on a particular session?

A

session.setMaxInactiveInterval(TimeInSeconds);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you create, set an expiration time, and send a cookie to the client?

A

new Cookie(“name”, value);

cookie. setMaxAge(secondsToExpire) – Also -1 to expire on browser restart.
response. addCookie(cookie)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you find a Cookie from a request?

A

There is no way to get a particular cookie, we need to get them all and loop to find the one we need.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly