Introduction:
Add this piece of code in web.xml
Test.jsp
Output:
1. The JSP implicit application object is an instance of a java class that implements the javax.servlet.ServletContext interface.
2. It gives facility for a JSP page to obtain and set information about the web application in which it is running.
Methods of Application Object:
There are numerous methods available for Application object. Some of the methods of Application object are:
1.getAttribute(String name) | The method getAttribute of Application object is used to return the attribute with the specified name. |
2,getAttributeNames | The method getAttributeNames of Application object is used to return the attribute names available within the application. |
3.setAttribute(String objName, Object object) | The method setAttribute of Application object is used to store the object with the given object name in the application. |
4.removeAttribute(String objName) | The method removeAttribute of Application object is used to remove the name of the object mentioned in parameter of this method from the object of the application. |
5.getMinorVersion() | The method getMinorVersion of Application object is used to return the minor version of the Servlet API for the JSP Container. |
6.getServerInfo() | The method getServerInfo of Application object is used to return the name and version number of the JRun servlet engine. |
7.getInitParameter(String name) | The method getInitParameter of Application object is used to return the value of an initialization parameter. |
8.getInitParameterNames | The method getInitParameterNames of Application object is used to return the name of each initialization parameter. |
9.getResourceAsStream(Path) | The method getResourceAsStream of Application object is used to translate the resource URL mentioned as parameter in the method into an input stream to read. |
10.log(Message) | The method log of Application object is used to write a text string to the JSP Container’s default log file. |
11.getMajorVersion() | The method getMajorVersion of Application object is used to return the major version of the Servlet API for the JSP Container. |
Example:
<context-param> <param-name>user</param-name> <param-value>chamu0001</param-value> </context-param> |
Test.jsp
<%@ page session="true" %> <% application.setAttribute("SITE", "MYJAVAHUB.COM"); %> <table border= 2> <% out.println("<tr><td>Major version: </td><td>" + application.getMajorVersion()+"</td></tr>"); out.println("<tr><td>Minor version:</td><td> " + application.getMinorVersion()+"</td></tr>"); out.println("<tr><td>Servlet engine version </td><td>" + application.getServerInfo()+"</td></tr>"); out.println("<tr><td>User init parameter: </td><td>" +application.getInitParameter("user")+"</td></tr>"); out.println("<tr><td>SITE </td><td>" + application.getAttribute("SITE")+"</td></tr>"); %> </table> |
Output:
10. The article is so appealing. You should read this article before choosing the Big data service providers you want to learn.
ReplyDelete