131
Example of out implicit Object
Example of request implicit object
Example of Response implicit Object
Example of config implicit object
Example of session implicit object
Example of pageContext implicit object
Example of page implicit object
Example of exception implicit object
5) JSP application implicit object
In JSP, application is an implicit object of type ServletContext.
The instance of ServletContext is created only once by the web container when application or project is deployed on the server.
This object can be used to get initialization parameter from configuaration file (web.xml). It can also be used to get, set or remove attribute from the application scope.
This initialization parameter can be used by all jsp pages.
Example of application implicit object:
index.html
<form action="welcome"> <input type="text" name="uname"> <input type="submit" value="go"><br/> </form>
web.xml file
<web-app> <servlet> <servlet-name>tutoraspire</servlet-name> <jsp-file>/welcome.jsp</jsp-file> </servlet> <servlet-mapping> <servlet-name>tutoraspire</servlet-name> <url-pattern>/welcome</url-pattern> </servlet-mapping> <context-param> <param-name>dname</param-name> <param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value> </context-param> </web-app>
welcome.jsp
<% out.print("Welcome "+request.getParameter("uname")); String driver=application.getInitParameter("dname"); out.print("driver name is="+driver); %>
Output
Other topics in JSP implicit Objects
Example of request implicit object
Example of Response implicit Object
Example of config implicit object
Example of session implicit object
Example of pageContext implicit object
Example of page implicit object
Example of exception implicit object