Expression Language Implicit Variables in JSP.

How are Implicit Variables used in JSP?


Implicit variables are those which are instantiated automatically and are references to objects created by the JSP EL language. These are provided by default by the JSP container.

Following are the list of implicit objects provided by JSP.
Variables Description
pageScope Collection of all page scope variables
requestScope Collection of all request scope variables
sessionScope Collection of all session scope variables
applicationScope Collection of all application scope variables
param Collection of all request parameter as single string value per parameter
paramValue Collection of all request parameter as string array per parameter
header Collection of all request header values as a single string value per header
headerValues Collection of all request header values as string array per header.
cookie Collection of all request cookie values as javax.servlet.http.Cookie value per cookie
intiParam Collection of all application intialization parameter as single string value per value
pageContext Instance of javax.servlet.jsp.Pagecontext class to access various request data.

Example :

<%@ taglib uri=""
prefix="fn" %>
<%@ taglib uri=""
prefix="c" %>
<form action="implicit1.jsp" method="GET">
NAME:<input type="text" name="nam">
<input type="submit">
: ${param.nam}</p>
: ${header["host"]}</p>
<p><b>USER AGENT</b>:${header["user-agent"]}</p>
Result :

NAME : alex
HEADER : localhost:8080
USER AGENT:Mozilla/5.0 (Windows; U; Windows NT 5.1;
en-US; rv: Firefox/3.0.15

In the above example we have used the implicit variables "param" and "header" to display the name entered, header, browser details etc.

Ask Questions

Ask Question