Main Menu
Lecture 1
Lecture 2
Lecture 4
Lecture 5
Lecture 6
Lecture 7
 

 

 

Session Control Points

1. Session Startup
Once launched, application waits for requests

When the top page URL is requested a new session is started for the new user

This is your 1st opportunity to customise interactions with this particular user

public Session() {
super();
/* ** Put your per-session initialization code here ** */
System.out.println("Second step: Session starts");
}

2. Session Runs
The Session object handles an open ended series of requests for service from the site

3. Session shutdown
When user interactions conclude, the session will terminate

Automatically terminate after a timeout period of no interaction - default is 1 hour

Releases resources which improves scalability and enhances security

The default timeout for all sessions is set in the application class

public Application() {
super();
/* ** Put your application initialization code here ** */
System.out.println("First step: Server starting up");
//change the default session time out in seconds
setSessionTimeOut (new Integer (60 * 10));
}

You can also set the time out for a particular session in the session constructor

You can end the session when you want to, e.g. when the customer has finished placing an order

Session().terminate;
You can override terminate to cleanup the session
public void terminate() {
/* ** Put your session shutdown code here ** */
System.out.println("Second last step: Session shutdown");
super.terminate();
}

Lecture 3 Demo 1 (Download)