File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes use of servlet for this app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "use of servlet for this app" Watch "use of servlet for this app" New topic

use of servlet for this app

H Wilson
Ranch Hand

Joined: Feb 23, 2005
Posts: 33
I am in the analysis phase of a project with the following specs (in a nutshell):

Allow users to save their searches for the journals in our database and receive via email periodic reports (they may choose a frequency of daily, weekly, monthly) listing new journals added to our database matching their search.

It seems obvious that I want to create a table containing fields for the actual search (query text), the user id, email address to send the report to, the frequency of the report, the date report was last run, and the date the report expires. (Those are the essential fields. I may discover additional fields as I delve further into this project.)

The application will run a nightly cron job to generate the reports. In my idea for its implementation, it would iterate over the search table described above, creating and emailing each report. Actually, I will probably query the search table for reports that are due to run that night and iterate over that result set.

My question here is about the use of a servlet for this job. Couldn't I create one object to iterate through the "reports due" result set and submit the process of creating and emailing the reports to a servlet? I'm thinking that such an implementation would allow for a multi-threaded solution. Obviously, iterating over a result set is sequential, but if I call a servlet to do the actual processing, don't I have multi-threading in that the app could call the servlet again before finishing each request? The iterating object would not have to wait for the servlet to finish generating one report before going to the next record in the result set and calling the servlet again, right?

Is there a better way to handle this process?

Sorry for the lengthy post and thanks in advance.
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149

you would need a client that fires a series of requests to your servlet with appropriate parameters.

As i understand it, you mainly are interested in the multithreaded nature of a servlet.

If this is really the only thing that makes you think of a servlet you might consider to use a simple multithreaded application that does the same without having the overhead of the servlet container.

I agree. Here's the link:
subject: use of servlet for this app
It's not a secret anymore!