Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Rose Howard   on Mar 14 In Java Category.

  
Question Answered By: Ujala Hashmi   on Mar 14

I think if you place an specifiec object for example a String into the session  first time a user  called your front servlet or your front/home JSP

by this snippet: (in the doGet method of your front servlet)


String userName = null;

userName = request.getParameter("user_name");

if (userName == null) {

final HttpSession session = request.getSession();


if (session.getAttribute("USER_LOGIN") != null) {
/** do normal forwarding to other parts of system **/
} else {
/** forward to a page which asks the user name/password from user and then sends them to this front servlet again **/
request.getRequestDipatcher("login.jsp").forward(req, res);
}
return;
}


session.setAttribute("USER_LOGIN", userName);

and then:

Thread thread = new Thread() {
public void run() {

sleep(30*60*1000);
session.invalidate();
}
}

thread.start();

Share: 

 
 
Didn't find what you were looking for? Find more on sessions Or get search suggestion and latest updates.


Tagged: