How to access request attributes in JSP?
I am currently using:
<% final String message = (String) request.getAttribute ("Error_Message"); %> and then
<%= message %> However, I am wondering if this can be done using EL or JSTL instead of using a script.
EL expression:
${requestScope.Error_Message} JSP EL has several implicit objects. See Expression Language in the Implicit Objects header.
Using JSTL:
<c:set var="message" value='${requestScope["Error_Message"]}' /> Here var sets the variable name and request.getAttribute equals requestScope . But it is not important. $ {Error_Message} will give you the same result. He will seek all possibilities. If you want to perform some operation on the contents that you take with Error_Message , you need to do this with a message . as below.
<c:out value="${message}"/> Just noting this here if anyone else has a similar problem.
If you send the request directly to the JSP using the Apache Tomcat web.xml configuration, then ${requestScope.attr} does not seem to work, instead, ${param.attr} contains the attr request attribute.