JSP – Config Implicit Object

JSP Config Implicit Object

  • JSP config object is an instance of javax.servlet.ServletConfig.
  • This object is used to get the configuration information about a page like servlet name, servlet context, configuration parameters etc.

index.jsp:

<html>
            <head>
                        <title>config implicit object example</title>
            </head>
            <body>
                        <h3>To see the website name click on the below link.</h3>
                        <a href=”welcome.jsp”>Click here</a>
            </body>
</html>

welcome.jsp:

<html>
            <head>
                        <title>config implicit object</title>
            </head>
            <body>
                        <%
                           String site = config.getInitParameter(“siteName”);
                           out.print(“Company website: ” + site);
                        %>
            </body>
</html>

web.xml:

<web-app>
            <servlet>
                        <servlet-name>welcomeServlet</servlet-name>
                        <jsp-file>/welcome.jsp</jsp-file>
                        <init-param>
                                    <param-name>siteName</param-name>
                                    <param-value>www.ameerpettechnologies.com</param-value>
                        </init-param>
            </servlet>
 
            <servlet-mapping>
                        <servlet-name>welcomeServlet</servlet-name>
                        <url-pattern>/welcome.jsp</url-pattern>
            </servlet-mapping>
                       
            <welcome-file-list>
                        <welcome-file>index.jsp</welcome-file>
            </welcome-file-list>
</web-app>

Scroll to Top