JSP Tutorials

JSP Application
Previous Home Next
adplus-dvertising

JSP Application

When JSP application is an implicit object which type of ServletContext.

In JSP Application is used ServletContext and which created with web container with application or project is deployed on the server.

When we get initialization parameter by configuaration file (web.xml) and also be used to get, set or remove attribute from the application .

This initialization parameter can be used by all jsp pages.

Example

index.html
    <form action="welcome">  
    <input type="text" name="uname">  
    <input type="submit" value="go"><br/>  
    </form> 
web.xml
    <web-app>  
    <servlet>  
    <servlet-name>sonoojaiswal</servlet-name>  
    <jsp-file>/welcome.jsp</servlet-class>  
    </servlet>  
    <servlet-mapping>  
    <servlet-name>sonoojaiswal</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 :

Previous Home Next