You should always use getParameter, when attribute come from GET or POST method. And use getAttribute when request is forwarded from another servlet/jsp. Such as :
ServletA:
request.setAttribute("test","value")
request.getRequestDispatcher("/ServletB").forward(request, response)
ServletB:
request.getAttribute("test") <-- you can get test attribute by using getAttribute
Related Contents:
- HttpServletRequest get JSON POST data [duplicate]
- Getting request payload from POST request in Java servlet
- Get the POST request body from HttpServletRequest
- Create a simple HTTP server with Java?
- Pass Hidden parameters using response.sendRedirect()
- Receiving null Value while using POST method in servlet?
- Java – sending HTTP parameters via POST method easily
- doGet and doPost in Servlets
- What does servletcontext.getRealPath(“/”) mean and when should I use it
- Is it safe to use a static java.sql.Connection instance in a multithreaded system?
- How to use a servlet filter in Java to change an incoming servlet request url?
- Difference between getAttribute() and getParameter()
- How to access static resources when mapping a global front controller servlet on /*
- How to solve javax.net.ssl.SSLHandshakeException Error?
- What is WEB-INF used for in a Java EE web application?
- Implementing a simple file download servlet [duplicate]
- Calling a servlet from JSP file on page load
- Spring MVC @PathVariable getting truncated
- Should one call .close() on HttpServletResponse.getOutputStream()/.getWriter()?
- Secure HTTP Post in Android
- How to specify the default error page in web.xml?
- How do you remove a Cookie in a Java Servlet
- How do I keep a user logged into my site for months?
- How to force browser to download file?
- Unable to compile class for JSP: The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
- Adding an HTTP Header to the request in a servlet filter
- How to configure Tomcat to connect with MySQL
- Mapping a specific servlet to be the default servlet in Tomcat
- calling a java servlet from javascript [duplicate]
- Best option for Session management in Java
- Session is lost and created as new in every servlet request
- Can I serve JSPs from inside a JAR in lib, or is there a workaround?
- HttpServletRequest – setCharacterEncoding seems to do nothing
- _jspService is exceeding the 65535 bytes limit
- Error 415 Unsupported Media Type: POST not reaching REST if JSON, but it does if XML
- java.net.SocketException: socket failed: EPERM (Operation not permitted)
- SessionTimeout: web.xml vs session.maxInactiveInterval()
- Howto get rid of ?
- Spring get current ApplicationContext
- How can I get the HTTP status code out of a ServletResponse in a ServletFilter?
- Exposing resources from jar files in web applications (Tomcat7)
- How to implement pagination in Spring MVC 3 [closed]
- How can I share a variable or object between two or more Servlets?
- Uploadify plugin doesn’t call Java Servlet
- Do I really need web.xml for a Servlet based Java web application?
- Different ways to get Servlet Context
- How to deploy a JAX-RS application?
- The ultimate Java version table (J2EE, Java EE, Servlet, JSP, JSTL)
- Spring injection Into Servlet
- Using ServletOutputStream to write very large files in a Java servlet without memory issues