This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletConfig : is it created one for each servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "ServletConfig : is it created one for each servlet?" Watch "ServletConfig : is it created one for each servlet?" New topic
Author

ServletConfig : is it created one for each servlet?

Sekhar Kadiyala
Ranch Hand

Joined: Feb 17, 2004
Posts: 170
ServletConfig object is created one for each servlet or one for each instance. When i mean instance, i guess, we can create multiple instances for the same servlet.

Thanks in advance!


PMP CSQA SCJP SCWCD SCBCD INS 21 INS 23
Bin Gao
Greenhorn

Joined: Jul 23, 2004
Posts: 12
I think that the servlet container should create one servletConfig for each servlet instance. We can see the protype of function init:
public init(ServletConfig servletConfig);

When one servlet is created, the init(ServletConfig) will be called once.
Kaspar Minosiantz
Ranch Hand

Joined: Sep 25, 2003
Posts: 36
IMHO ServletConfig object is created one for each servlet .
For instance when we create


OurServlet inherits an implementation of ServletConfig form GenericServlet
[ August 19, 2004: Message edited by: Kaspar Minosiantz ]

SCJP 1.4 SCWCD 1.4 <a href="http://www.jroller.com/page/kaspar_ru" target="_blank" rel="nofollow">blog</a>
Ian Perkins
Greenhorn

Joined: Dec 18, 2003
Posts: 19
The servlet container will only create one instance of each servlet; that is why writing thread-safe code is so important...

Therefore, by definition, there can only be one ServletConfig for each servlet.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: ServletConfig : is it created one for each servlet?
 
Similar Threads
how many instances???
Shared instance variable
Multiple threads of a servlet instance and servletConfig
Regarding the init() methods
servlet config and servlet context