I am using a javax.servlet.http.HttpServletRequest to implement a web application.
I have no problem to get the parameter of a request using the getParameter method. However I don’t know how to set a parameter in my request.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t, not using the standard API.
HttpServletRequestrepresent a request received by the server, and so adding new parameters is not a valid option (as far as the API is concerned).You could in principle implement a subclass of
HttpServletRequestWrapperwhich wraps the original request, and intercepts thegetParameter()methods, and pass the wrapped request on when you forward.If you go this route, you should use a
Filterto replace yourHttpServletRequestwith aHttpServletRequestWrapper: