Forums Register Login

ServletConfig : is it created one for each servlet?

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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 ]
+Pie Number of slices to send: Send
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.
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 838 times.
Similar Threads
Regarding the init() methods
Multiple threads of a servlet instance and servletConfig
Shared instance variable
servlet config and servlet context
how many instances???
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:14:16.