Created a session from the login.jsp page using a servlet
String msg = "";
HttpSession sess = request.getSession();
// if(sess != null)
//sess.invalidate();
if (sess.getId() != null) {
sess.setAttribute("uname", uname);
sess.setAttribute("pwd", pwd);
}
Retrieved the session in another JSP page using:
<b> Welcome ${uname}</b>
Logout hyperlink:
<a href="login_ml.jsp" id="logout_link" onclick='lgt()'>Logout</a></td>
Javascript function to clear session:
function lgt(){
var logout = document.getElementById("logout_link");
logout.session.clear();
alert("logout");
}