EL Implicit Object initParam

initParam

     


By using this implicit object we can access context initialization parameters.

 ExpressionLanguage
Jsp  code
initParam.user
application.getInitParameter ( “user”)

Ex: ${initParam.user}   Output : scott
        ${initParam.pwd}   Output:Blank space.
Add this piece of code in web.xml

<context-param>
          <param-name>user</param-name>
          <param-value>chamu0001</param-value>
</context-param>
<context-param>
          <param-name>password</param-name>
          <param-value>myjavahub</param-value>
</context-param>
 test.jsp

<%@ page isELIgnored="false" %>
<%
Cookie cookie = new Cookie ("username","chamu");
cookie.setMaxAge(60 * 60);
response.addCookie(cookie);
%>
<table border= 2>
<tr><td><h2>initParam.user</h2></td> <td><h2>${initParam.user}</h2></td></tr>
<tr><td><h2>initParam.password</h2></td> <td><h2>${initParam.password}</h2></td></tr>
</table>

Output:  http://localhost:8080/Scwcd_jsp/test.jsp


             
Thanks For Making This Possible! Kindly Bookmark and Share it.

Technorati Digg This Stumble Stumble Facebook Twitter

No comments:

Post a Comment