The moose likes Servlets and the fly likes Servlet Being Loaded Morethan Once Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Being Loaded Morethan Once" Watch "Servlet Being Loaded Morethan Once" New topic

Servlet Being Loaded Morethan Once

Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Recently encountered one funny scenario, where servlet is being called morethan once.
The flow something looks like,

JSP ---> Servlet ---> Business Object (BO)
Actually JSP passes necessary parameters (about 5) to the Servlet and this Servlet calls BO with request parameters, BO queries the Database and gets about 1000 Emails and calls some utility program to send parameters to all the 1000 Emails. Since this sending of content to recipients taking around 15-20 mins including establishing and closing SMTP connection for every 10 emails, in this process the user in the front-end sees the processing until job finishes (ie., after 15-20 mins).
So far is fine except sometimes observed Servlet being loaded multiple times
which enables the BO to send Emails morethan once to the recipient which is ERROR. The log file shows Servlet.init() being called morethan once but user in front-end submitted the request only once. This problem is intermittent bcoz sometime is okay it submits only once. Dont quite understand the problem. And also there's no clustering environment it just uses one instance of WLS.
Any ideas about this behaviour ??

SCJP 1.5, SCEA, ICED (287,484,486)
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
One known cause of servlet init() being called more than once has to do with the servlet being addressed multiple ways. For example - using the "servlet/" URL nomenclature that goes through the "invoker" servlet while also having a direct URL defined in web.xml.
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Thanks Brogden. What could be other reason as only one instance of Servlet is addressed inside properties file, we're using WLS5.1
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Any updates ?? Thanks.
I agree. Here's the link:
subject: Servlet Being Loaded Morethan Once
It's not a secret anymore!