Mega Code Archive

 
Categories / Java / JSP
 

Expression Language Examples

<html> <head> <title><!-- be aware that this listing will not work in Tomcat 4.1, or any other container that does not support the use of the expression language outside of tags --> <html> <head> <title>Expression Language Examples</title> <%   // set up a page context parameter for use later in the page   // normally this would have been set within the context of   // an application   pageContext.setAttribute("pageColor", "blue"); %> </head> <body bgcolor="${pageScope.pageColor}"> <h1>Welcome to the ${param.department} Department</h1> Here are some basic comparisons: <p> Is 1 less than 2? ${1<2} <br> Does 5 equal 5? ${5==5} <br> Is 6 greater than 7? ${6 gt 7}<br> <p>Now for some math:<br> 6 + 7 = ${6+7}<br> 8 x 9 = ${8*9}<br> <hr>You appear to be using the following browser: ${header["user-agent"]} </body> </html></title>