I have one
jsp in which i enter username and password.It calls another jsp which set loginId and some other stuff in session.Now when i click on one hyperlink which is calling a
servlet through javascript function , in the servlet i use this code:-
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try{
HttpSession session = request.getSession(false);
if(session==null){
response.sendRedirect("./loginForCSR.jsp");
return;
}
RegistrationDAL registrationDAL = new RegistrationDAL();
ArrayList<ApprovalBean> appList = new ArrayList<ApprovalBean> ();
int tcount =0;
/*if (request.getSession().isNew()){
response.sendRedirect("./loginForCSR.jsp");
return;
}*/
//else{
if(session.getAttribute("ApprovalList")!=null)
session.removeAttribute("ApprovalList");
if(session.getAttribute("tCount")!=null)
session.removeAttribute("tCount");
but for the first time it logout automatically
.And after that it works perfectly .Can anybody tell me the reason of this behaviour.