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> |
<%@ 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
No comments:
Post a Comment