How do I pass a parameter from a servlet to a JSP?

JIA Java Italian Association

Check out this answer. The logic is the same, but it's reversed.

You insert the object you need in the request scope with request.setAttribute() and then you use the RequestDispatcher to forward or include the jsp page.

In the JSP page you use request.getAttribute() to get the object(s) back.

If you need to read the form parameters, you just use the RequestDispatcher, because it passes the request object.

See also: