How to clear the HttpServletRequest

I wish to do is clear up all the parameters and attributes in the request(HttpServletRequest) pass by client, and set a new attribute, and dispatch it to another page, to summarize it in code:

//clear up all the parameters and attributes in the request pass by client<--How to do this

request.setAttribute("NewAttribute", "value");

dispatcher.forward(request, response);

I can't find a method like request.clear(). Is there a corresponding method that can do this?

[499 byte] By [williameea] at [2007-11-26 22:50:30]
# 1

The request object's life time is restricted only to the scope of the HTTP Request.

Which means, the same request object will not be available for the next HTTP Request cycle.

But if you are doing a HTTP Forward , then I think the Request cycle is retained....

You could set the request object to null ?

Also instead of Http Forward , you could perform an Http Redirect with the sendRedirect method - this is guranteed to create a new Http Request, thus invalidating the previous Http Request anyway.

appy77a at 2007-7-10 12:11:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

You can use:

ServletRequest.removeAttribute. Specifications: "Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled."

The parameters (<> attributes) of the request can't be either removed nor set, as long as I know.

abc0xyza at 2007-7-10 12:11:46 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...