VOOZH about

URL: https://www.geeksforgeeks.org/java/jsp-config-implicit-objects/

⇱ JSP Config - Implicit Objects - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JSP Config - Implicit Objects

Last Updated : 16 May, 2026

JavaServer Pages (JSP) provides implicit objects to simplify web development. The config implicit object is used to access configuration details of a JSP page. It helps retrieve initialization parameters defined in the web.xml file.

  • The config object is an instance of ServletConfig.
  • It is used to fetch init parameters from web.xml.
  • Its scope is limited to a single JSP page.

Methods of ServletConfig

Methods of ServletConfig interface are listed alongside the action performed from the below table as follows:

  • getServletContext(): Returns the ServletContext object
  • getInitParameter(String name): Returns the value of a specific initialization parameter
  • getInitParameterNames(): Returns all parameter names
  • getServletName(): Returns the name of the servlet/JSP page

Step-by-Step Implementation

Step 1: Create index.html

  • Create a simple form to take user input
  • Use action="welcome" to map request to JSP

index.html File 

Step 2: Configure web.xml

  • Define servlet name and JSP file mapping
  • Add <init-param> to store configuration values
  • Map URL pattern to access JSP

web.xml File

Step 3: Create welcome.jsp

  • Access user input using request.getParameter()
  • Use config.getInitParameter() to fetch value
  • Display output using out object.  

welcome.jsp FIle

Step 4: Run the Application

  • Deploy project on server (e.g., Tomcat)
  • Open browser and run index.html
  • Enter name and click go

Output:

These are the screenshots of the outputs of the above JSP page.

👁 Image
👁 Image
👁 Image

Advantages

  • Helps separate configuration from code, improving maintainability.
  • Allows easy access to initialization parameters defined in web.xml.
  • Provides page-specific configuration, making it flexible for different JSP pages.
Comment
Article Tags:
Article Tags: