Create a JSP page to demonstrate the use of Expression language.

login.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>  

<%  

    application.setAttribute("author", "Rupam Gupta");      application.setAttribute("country", "India");  

    %>  

<!DOCTYPE html>  

<html>  

    <head>  

        <title>Expression Language</title>  

    </head>  

    <body>  

        <form action="Show.jsp">  

            User First Name:<input type="text" name="uname"/><br> <br>  

            User Last Name:<input type="text" name="lname"/><br><br>   

            <input type="submit" value="Check EL Use!!"/>  

        </form>  

    </body>  

</html>

login.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>  
<% pageContext.setAttribute("colour", "olive");%>  
<!DOCTYPE html>  
<html>  
    <head>  
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">  
             <title>JSP Page</title>  
    </head>  
    <body bgcolor="${pageScope.colour}">  
        <b>Welcome ${param.uname}${param.lname}</b><br>          
Below we are accessing Application object:  
        <p>  
            Author Name:<b>${applicationScope.author}</b>  
        </p>  
        Below we are accessing Session object:  
        <p>  
            Author Country:<b>${sessionScope.country}</b>  
        </p>  
        Below we are showing some basic comparisons Using EL:  
        <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 Maths:<br>  
            6+7=${6+7}<br>  
            8*9=${8*9}<br>  
        <hr> You appear to be using the following browser:  
        ${header["user-agesnt"]}  
    </body>  
</html> 







Post a Comment

0 Comments