March 8th, 2001, 04:20 PM
Is there a way to remove a parameter from the request object.
i.e. you can access the parameter with
alternatively is there a way to set the parameter to something else?
maybe using request.setParameter("foo"); ???
March 8th, 2001, 05:42 PM
There is not a setParameter() method for the ServletRequest object or the HttpServletRequest object, nor the corresponding response objects either.
Can you explain more about what you are trying to do, and why?
March 8th, 2001, 05:47 PM
basically i'm just trying to eliminate some parameters after a function is run on a .jsp page. the request get's forwarded to a servlet and an error condition is to redirect back to the original page. however, if certain parameters are not removed, the page will behave funkily.
we have an alternate work around, but it involves hard coding something in the servlet. so deleting the parameters from the servler would be ideal.
March 9th, 2001, 08:57 AM
When you invoke the servlet, is it from an HTML form like this:
<form name=form1 method=post action=myServlet>
If so, maybe you could split your form into 2 different forms and place the parameters you don't want the servlet to know about in the second form.
Since I don't know exactly what you're trying to do I don't know if that would work or not, but that's all I got right now.
Hope that helps.
March 9th, 2001, 11:55 AM
Now there is a use case in which a user can make an error, be sent to the same page with error notification and then perform the error again and again be sent to the same page. the problem is that since there is that if we cannot remove the parameters, we then end up with an accumulation of serial errors, all with the same parameter name. ie:
notice the repitition of error1 and error2 in the request line
Calls to the request object will then, i think, only return the value of the first listed value for error1 and error2, and not the most current value of that error because "where you came from" includes the errors that happened to be sitting in the request object.
thus, i want to remove those errors upon handling them so that if an error happens again, we do not report past errors.
March 15th, 2001, 06:41 AM
Altering HTTP parameters sent with a request is tricky. One alternative is to write an implementation of the HttpServletRequest-interface, contains the true HttpServletRequest-object, a String(Buffer) representing the Query String and override the method getQueryString to return the modified query-string. I've tested this myself, and it is working fine for HTTP GET operations.
A more straightforward way is to use headers instead of parameters (possible if the resource generating the parameters is a servlet or JSP), whereas you can set and remove headers freely and it is possible to provide several headers with the same name!
A third way is to use a request or session attribute to pass objects (errors) to a JSP. Perhaps use some sort of list of the errors?
I hope I've at least given you some useful ideas.