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();