JSP - SPLessons

JSP Expression Language

Home > Lesson > Chapter 30
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

JSP Expression Language

JSP Expression Language

shape Description

The JSP Expression language is utilized to get the information which is put away in the Java bean class.JSP Expression language helps during the time spent getting to the information from bean properties and an implicit object. Expression language incorporates logical, arithmetic and relation operation as well. Syntax
${ expression}
Following are the implicit objects will be used in expression language.
Implicit object Purpose
applicationscope It maps given attribute name.
sessionscope The quality set in the session scope which maps given property name.
requestscope The quality set in the solicitation scope which maps given characteristic name.
pagescope The worth set in the page scope which maps given property name.
paramvalues Gets the array of values of the request parameter.
param Gets the single value of the request parameter.
pagecontext It can access to many object request, session, application, page.
headervalues Gets the cookie value of given cookie name.
cookies Gets the cookie value of given cookie name.
initparam initparam maps the parameters to initialize.
header Gets the single value of the request header name.
Following are the precedence operators and reserve keywords used in JSP Expression Language.
Precedence operators Reserve keywords
[] . instanceof
+ - (binary) mod
|| or gt
== != eq ne and
() empty
< <= > >= lt le gt ge div
* / div % mod true
&& and le
-(unary) not ! empty null
?: false
pagecontext or

shape Example

Following is an example for JSP Expression Language. explan.jsp [java] <html> <body> <form action="studetails.jsp"> Student Name: <input type="text" name="studentName" /></br> Student RollNum: <input type="text" name="rollNo" /></br> <input type="submit" value="Click Here To submit"/> </form> </body> </html> [/java] Here just created two text boxes one is for Student Name, another is for Student RollNum and also created submit buton that is Click Here To submit. studetails.jsp [java] <html> <body> Student name is ${ param.studentName } </br> Student Roll No is ${ param.rollNo } </body> </html> [/java] Output: Output will be as follows, where created two text fields for student name and roll number, when click on submit stdetails.jsp file will be displayed in the URL bar. After entered the details of student, output will be as follows.

Summary

shape Key Points

  • Precedence of an operator and reserve keywords also will be used in expression language.
  • Expression language is modern quality of the JSP version 2.0.