I created a registration page (r.jsp
) where we can enter user details. Upon clicking the submit button, the servlet is hit and it will perform the business logic. If successful, it redirects to x.jsp
otherwise if it failed it redirects to r.jsp
.
The problem I am having is when there is a failure and it redirects to r.jsp
, data entered by the user is lost. I would like to retain it.
Below is the code I am performing in the servlet:
if (appResponse.getMessageStatus().equalsIgnoreCase(AppConstants.SUCCESS)) {
request.setAttribute("message", appResponse.getMessage());
url = "/x.jsp";
} else {
request.setAttribute("message", appResponse.getMessage());
url = "/r.jsp";
}
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);