How to set a parameter in a HttpServletRequest?

后端 未结 7 702
感动是毒
感动是毒 2021-02-01 03:16

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 getParamete

7条回答
  •  余生分开走
    2021-02-01 03:40

    From your question, I think what you are trying to do is to store something (an object, a string...) to foward it then to another servlet, using RequestDispatcher(). To do this you don't need to set a paramater but an attribute using

    void setAttribute(String name, Object o);
    

    and then

    Object getAttribute(String name);
    

提交回复
热议问题