Difference between getAttribute() and getParameter()

后端 未结 10 2157
情话喂你
情话喂你 2020-11-22 08:44

What is the difference between getAttribute() and getParameter() methods within HttpServletRequest class?

10条回答
  •  既然无缘
    2020-11-22 08:59

    getParameter - Is used for getting the information you need from the Client's HTML page

    getAttribute - This is used for getting the parameters set previously in another or the same JSP or Servlet page.

    Basically, if you are forwarding or just going from one jsp/servlet to another one, there is no way to have the information you want unless you choose to put them in an Object and use the set-attribute to store in a Session variable.

    Using getAttribute, you can retrieve the Session variable.

提交回复
热议问题