This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
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
Author

Servlet Being Loaded Morethan Once

Anil Vupputuri
Ranch Hand

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

POST
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 ??
Thanks.


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

Joined: Mar 22, 2000
Posts: 12792
    
    5
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.
Bill
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
Cheers,
Anil
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
Any updates ?? Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet Being Loaded Morethan Once