In your doFilter() method you should be able to do request.setAttribute(“name”, value); and then access that parameter after the RequestDispatcher.forward() call in your JSP as you have done, i.e. using request.getParameter();
Parameters may not be set, and are not interchangeable with attributes.
Parameters come from form elements, or from being appended to the url query (the portion after the ? you’ll see in the address bar if you use method=get)
Part 2 sort of contradicts what I just said about not being able to set them, what I mean is that there is no setParameter defined in HttpServletRequest.
You can add a hidden field to the form and add the parameter that way, or use set/getAttribute
If you really want to add a parameter you can implement a new request using the real one as a delegate (see HttpServletRequestWrapper) and override the getParameter(String s) method (obviously you’ll have to add the extra parameters in the constructor or by a new method). Once you’ve done that just do something like:
What I do is wrap HttpServletRequest with my own request object in which I have added the functionality to add / remove request parameters.
You could do the same and use a filter to to the wrapping, although you might encounter the odd cast exception if you are using code that expects a specific class of Request.