In servlet how to increase session time-out programitacally?
>> Monday, May 30, 2011
Session:It is the time duration,which starts the starting point of client to server conversation and which terminates the end point of server to client conversation.
Example:
Example:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class SimpleSession extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
response.setContentType("text/html");
java.io.PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
Start body tag
out.println("Session Info
");
out.println("session Id: " + session.getId() + "
");
out.println("The SESSION TIMEOUT period is "
+ session.getMaxInactiveInterval() + " seconds.
");
out.println("Now changing it to 20 minutes.
");
session.setMaxInactiveInterval(20 * 60);//it can be used to set session programitically
out.println("The SESSION TIMEOUT period is now "
+ session.getMaxInactiveInterval() + " seconds.");
end body tag
}
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
java.io.IOException {
doGet(request, response);
}
}
0 comments:
Post a Comment