Search code examples
javajsprequestdispatcher

Add text java requestDispatcher


I want to direct the user back to the previous page with the same get in the url

if (somecheck) { 
 req.getRequestDispatcher("register.jsp?email="+req.getParameter("email")).forward(req, resp);
}

But this directs the user to "/register.jsp" instead of "/register.jsp?email=testemail@mail.com"

How can i add the email to the url?


Solution

  • Solution is using response.sendRedirect("register.jsp?email="+req.getParameter("email")); thanks to Anton Dovzhenko