File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes what is the use of servlet config object?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "what is the use of servlet config object??" Watch "what is the use of servlet config object??" New topic
Author

what is the use of servlet config object??

senthil sen
Ranch Hand

Joined: Oct 10, 2002
Posts: 184
what is the use of the servlet object??and where can it be used often...
Nikki Aniban
Greenhorn

Joined: Oct 10, 2002
Posts: 14
Hi! ServletConfig is an interface that has defined methods where you can get the initialization parameters that you specified for a particular servlet in your web.xml.
For example your web.xml look like this:
<servlet>
<servlet-name>MyServlet</servlet-name>
<servlet-class>MyServlet</servlet-class>
<init-param>
<param-name>name</param-name>
<param-value>diego</param-value>
</init-param>
</servlet>
then in your servlet you can use this code to get the value of "diego":
getServletConfig().getInitParameter("name");
Just check the API to see the other methods that are defined. But wait, here's the clincher, the ServletConfig is implemented by GenericServlet which is in turn, extended by HttpServlet. So, in the ideal world, you don't have to create an instance of ServletConfig just to get initialization parameters because you can directly access it from your servlet.
Bottomline is: ServletConfig is not used often.
Hope this answers your question.
Jagdeep Singh
Ranch Hand

Joined: Oct 14, 2002
Posts: 106
ServletConfig is a abstract interface and this object is used by a servlet CONTAINER to pass information to a servlet(s)during initialization.


Jagdeep Singh<br />SCJP;SCWCD;IBM Certified XML Solution Developer;SCBCD1.3
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: what is the use of servlet config object??
 
Similar Threads
transfering objects to applets
More Than One Object To A Servlet
what is single threded model
servlet
what is servlet config