Jeeppp
Jeeppp

Reputation: 1573

request param not set in jsp request dispatcher

I'm doing a request forward to another JSP from a JSP with some params in the request object.

JSP1

        session.invalidate();
        request.setAttribute("errorMessage", "Invalid user or password");

        RequestDispatcher requestDispatcher; 
        requestDispatcher = request.getRequestDispatcher("/userlogin.jsp");
        requestDispatcher.forward(request, response);;

userlogin.jsp

<%
if(null!=request.getAttribute("errorMessage"))
{ %>
<div class="alert alert-danger display-hide">
                <button class="close" data-close="alert"></button>
                <span> <%=request.getAttribute("errorMessage")%> </span>
            </div>

 <%   }
   else{
    System.out.println("no request");
  }
%>

Now Im not able to get the request parms from the request. Its always null in userlogin.jsp. any help?

Upvotes: 0

Views: 116

Answers (2)

aurox
aurox

Reputation: 117

Move session.invalidate() in userLogin.jsp because If you invalidate the session your parameter are not retrieve.

Upvotes: 0

Swapan Pramanick
Swapan Pramanick

Reputation: 175

Can you try without the statement session.invalidate();

Upvotes: 1

Related Questions