#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    18
    Rep Power
    0

    Question


    Is there a way to remove a parameter from the request object.

    i.e. you can access the parameter with
    request.getParameter("paramName");

    alternatively is there a way to set the parameter to something else?
    maybe using request.setParameter("foo"); ???

    thanks

    me
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    46
    Rep Power
    14
    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?
    - MW
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    18
    Rep Power
    0
    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.

    thanks
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Colorado
    Posts
    46
    Rep Power
    14
    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.
    - MW
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Posts
    18
    Rep Power
    0

    better description


    OK,

    so here's the deal. we are passing parameters from the backend to a .jsp page upon certain errors happening. There is a combination of javascript and java code in the .jsp that changes the behavior of the .jsp page if those errors are passed.

    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:

    somePage.jsp?error1=theError&error2=theError&error1=theError&error2=theError

    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.



  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    0
    Rep Power
    0

    Lightbulb


    Hello!

    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.

IMN logo majestic logo threadwatch logo seochat tools logo