Methods | Return Type |
---|---|
getAttribute(string name) | Object |
getAttributeNames() | java.util.Enumeration |
getlnitparameter(string name) | String |
getlnitparameterNames() | java.util.Enumeration |
getRealPath(String path) | string |
getServerinfo() | string |
getMinorVersion() | int |
getMajorVersion() | int |
log(Message)() | string |
getAttribute(String name) method is used for returning attribute with specified name.
Syntax
getAttributeNames() method is used for returning all attribute names within the application.
Syntax
getlnitparameter(string name) method is used for returning intialiased parameter value. If parameter is not there then null value is returned.
Syntax
getlnitparameterNames() method is used for returning intialiased parameter name.Â
Syntax
getRealPath(String path) method is used for translating the resource URL mentioned as parameter in the method into an input stream to read.
Syntax
getServerinfo()method is used for returning name and version of the JRun servlet engine.
Syntax
getMinorVersion()method is used for returning the minor version of the Servlet API for the JSP Container.
Syntax
getMajorVersion()method is used for returning the major version of the Servlet API for the JSP Container.
Syntax
log(Message)()method is used for writing text string to the JSP Container.
Syntax
counter.jsp
<%@ page import="java.io.*,java.util.*" %> <html> <head> <title>Application Implicit Object Example</title> </head> <body> <% //Comment: This would return null for the first time Integer counter= (Integer)application.getAttribute("numberOfVisits"); if( counter ==null || counter == 0 ) { //Comment: For the very first Visitor counter = 1; } else { //Comment: For Others counter = counter+ 1; } application.setAttribute("numberOfVisits", counter); %> <h3>Total number of hits to this Page is: <%= counter%></h3> </body> </html>
This is the code to increase the count on the browser when refresh the page.
Output:
Output will be as follows.
While refreshing the page number hits will be increased as follows.