0

JSP can add new parameters to the HTTP request when forwarding using one or more <jsp:param> tags:

<jsp:forward page="newPage.jsp">
  <jsp:param name="param1" value="value1" />
  <jsp:param name="param2" value="value2" />
</jsp:forward>

How parameters can be added when forwarding from a Servlet?

RequestDispatcher dispatcher = request.getRequestDispatcher("/newPage.jsp");
// TODO: how to add parameters?
dispatcher.forward(request, response);
Danilo Piazzalunga
  • 7,590
  • 5
  • 49
  • 75

2 Answers2

2

You can concatenate parameters to URL as query parameters

RequestDispatcher dispatcher = request.getRequestDispatcher("/newPage.jsp?param1=value1&param2=value2");
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
-1

You need to create new HttpServletRequest because parameters are immutable. You can do it with HttpServletRequestWrapper for example.