I want Create Session in CheckForLogin Servlet and Use it in all JSP pages(For checking).
What should Write in my JSP pages and instead of ……… in Sevlet.How to define Session in Servlet?
public void service(ServletRequest request,
ServletResponse response) throws ServletException, IOException {
String email = request.getParameter("email");
String password = request.getParameter("password");
if (email.equals("") || password.equals("") || email == null || password == null) {
request.getRequestDispatcher("Error.jsp?err=enterdata").forward(request,response);
} else {
UserBl userBl = new UserBl();
if (userBl.checkUser(email, password)) {
..........................
request.getRequestDispatcher("Home.jsp").forward(request, response);
} else {
request.getRequestDispatcher("Error.jsp?err=nulluser").forward(request, response);
}
}
}
I Should Write HttpServletRequest instead of ServletRequest and HttpServletResponse instead of ServletResponse in method parameters and then Create Session and access to session