How to access a request attribute set by a servlet in JSP?

It's available in the default EL scope already, so just

${attrib}

should do.

If you like to explicitly specify the scope (EL will namely search the page, request, session and application scopes in sequence for the first non-null attribute value matching the attribute name), then you need to refer it by the scope map instead, which is ${requestScope} for the request scope

${requestScope.attrib}

This is only useful if you have possibly an attribute with exactly the same name in the page scope which would otherwise get precedence (but such case usually indicate poor design after all).

See also:

  • Our EL wiki page
  • Java EE 6 tutorial - Expression Language

Maybe a comparison between EL syntax and scriptlet syntax will help you understand the concept.

  • param is like request.getParameter()
  • requestScope is like request.getAttribute()

You need to tell request attribute from request parameter.


have you tried using an expression tag?

<%= request.getAttribute("attrib") %>