I'm trying to do something that looks small but it's failing. I'm trying to send a response message back to a jsp when login fails but not being able. As of now I can only redirect back to the jsp but cannot display a message from the servlet on it. This is the servlet part of the redirection:
if (count > 0) {
res.sendRedirect("adminHome.jsp");
} else {
res.sendRedirect("index.jsp");
}
I tried to print a message using PrintWriter and the redirect but failed because I couldn't get how to receive the message in the JSP. I also read that I shouldn't redirect but rather I should just forward from the servlet. How can I do this? Please help with the code patch to forward from servlet as well as that one to receive in JSP. Thanks
response.getWriter()
orgetOutputStream()
in servlet whenever you use forward/redirect. You will riskIllegalStateException
s.