Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet's "configuration" parameters

 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the API docs:
A ServletConfig object contains the servlet's configuration and initialization parameters.

The HFSJSP book explains very well about ServletConfig object's purpose to give us a servlet's init & startup parameters.
But I didn't find any discussion about "servlet's configuration parameters" in HFSJSP book. Could someone please provide some info about them?

Thanks!
 
Łukasz Suchecki
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's easy to check API:
getInitParameter(java.lang.String name)
getInitParameterNames()
getServletContext()
getServletName()

So we can assume that in spec they said 2 times the same - because initParameters = servlet configuration.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Faisal Pasha wrote:From the API docs:
A ServletConfig object contains the servlet's configuration and initialization parameters.


Where ? All I see is : "A servlet configuration object used by a servlet container to pass information to a servlet during initialization. ".
 
Ankit Garg
Sheriff
Posts: 9527
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically the servlet's name is the only servlet configuration the ServletConfig object provides to the servlet in addition to the initialization parameters. But we can't say that init parameters = servlet configuration...
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe, you can find it here:
Interface Servlet's API doc -> Method details for init(ServletConfig config) -> Parameters:
config - a ServletConfig object containing the servlet's configuration and initialization parameters

A bit down, inside the method details for getServletConfig() there is no mention of "configuration":
Returns a ServletConfig object, which contains initialization and startup parameters for this servlet.

Its confusing! Hope, you all agree.
 
Faisal Ahmad
Ranch Hand
Posts: 355
Chrome Java Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if ServletConfig object doesn't deals with any "configuration", then it should have been called as ServletInit object. I am sure it does deals with configuration for a servlet. But, how? What exactly a servlet configuration means??
 
Chinmaya Chowdary
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Faisal.

I think, 'configuration' means providing implementation to the ServletConfig API,

Container provides the implementation to the ServletConfig interface. During initialization time it creates the object(implemented class object) and pass it to the init(ServletConfig config) method. This happens by default. If we override this method, then ServletConfig and ServletContext objects will not be available to the servlet. This will remain as normal java object. It confirms that the class is not implementing Servlet API.

This provides the essential configuration to the java class to be a 'servlet'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic