Forums Register Login

init() method on servlets

+Pie Number of slices to send: Send
When the init method in a servlet is called? At the first request or when it is instantiated or it is instantiated when the first request is made?
+Pie Number of slices to send: Send
When the init method in a servlet is called?

After Loding servlet class and executing default constructor
At the first request or when it is instantiated or it is instantiated when the first request is made?

Best time to Load a Servlet class is decided by your server depending on the server confugration.

I am not able to recollect it but there is some tag called
<load-on-startup> (may be something diff)

Cheers
-Praful
[ October 05, 2004: Message edited by: Praful Thakare ]
+Pie Number of slices to send: Send
init is called only once when the servletcontext is initialised (basically when you start tomcat). <load-on-startup>1</load-on-startup> says this servlet has highest priority at loading. 2 and higher numbers are loaded after servlets with 1 are loaded. I am not sure whether this is guaranteed or just a guideline.
+Pie Number of slices to send: Send
I�m using Tomcat and if I put <load-on-startup>4</load-on-startup>, init() method is called when the context is initialized, if I don�t put, init() methos is called only whne the first request is made...
+Pie Number of slices to send: Send
Hi,
init will be called after executing the default constructor of the servlet, and a servlet config object shall be passed to init method,
This tiny ad will self destruct in five seconds.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 785 times.
Similar Threads
Instantiating Servlet
Servlet's constructor
A web application query
load on start up
When init() method is called?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:42:17.