Expression Language in JSP

Ads
 

Expression Language in JSP

EL means the expression language , it is a simple language for accessing data, it makes it possible to easily access application data stored in JavaBeans components.

EL means the expression language , it is a simple language for accessing data, it makes it possible to easily access application data stored in JavaBeans components.

Expression Language in JSP

        

EL means the expression language , it is a simple language for accessing data, it makes it possible to easily access application data stored in JavaBeans components. The jsp expression language allows a page author to access a bean using simple syntax such as $(name).  Before JSP 2.0, we could  use only  a scriptlet, JSP expression, or a custom tag to include server state in the jsp page output. Expression Language (EL) was first introduced in JSTL 1.0. EL makes it easier to integrate server side state with the presentation output. EL expressions are no longer limited to JSTL action attributes, but may be used in any standard or custom action attribute declared to accept a runtime expression. EL expressions can be used in static text. EL expressions can be used directly in template text outside of any actions.

EL expression is always written between the delimiters ${ and }. In the JSP page response, the result of expression evaluation replaces the expression and its delimiters in the template text. Within tags, expression can be used only in attribute values.

Code of the program is given below:

 

<html>
<head>
<title> Use of Expression Language in jsp</title></head>
<%pageContext.setAttribute("pageColor", "#FFFFDF");
%>
<body>
<table bgcolor=
"${pageScope.pageColor}" border
         ="1" cellpadding="0" cellspacing="0" 
align
="center" width="50%" height="50%">
<tr>
<td>
<b>Welcome to the Roseindia.net</b></td>
</tr>
<tr>
<td>
You appear to be using the following browser:<br>
${header["user-agent"]}
</td>
</tr>
</table>
</body>
</html>

Output of the Program:


 

Download this example.

Ads

Ads