Config Implicit Object in JSP by R4R Team

Config Implicit Object in JSP with examples:
It is an instance of javax.servlet.ServletConfig. Config Implicit object is used for getting configuration information for a particular JSP page. Using application implicit object we can get application-wide initialization parameters, however using Config we can get initialization parameters of an individual servlet mapping.
Methods of Config Implicit Object:

String getInitParameter(String paramname) Same what we discussed in application implicit object tutorial.
Enumeration getInitParameterNames() Returns enumeration of Initialization parameters.
ServletContext getServletContext() This method returns a reference to the Servlet context.
String getServletName() It returns the name of the servlet which we define in the web.xml file inside <servlet-name> tag.
Config Implicit Object Example:


Lets say below is my web.xml file. Im just defining servlet name and servlet mapping in it. Later, I would fetch few details from this file using config implicit object.











In this JSP page we are calling getServletName() method of config object for fetching the servlet name from web.xml file.


<head> <title> Config Implicit Object</title>




String sname=config.getServletName();

out.print("Servlet Name is: "+sname);




Leave a Comment:
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!