aspose file tools*
The moose likes Servlets and the fly likes Servlet to Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet to Servlet" Watch "Servlet to Servlet" New topic
Author

Servlet to Servlet

Yash Sharma
Ranch Hand

Joined: Jan 30, 2003
Posts: 61
I am working on a utility API. Basically, this would be a web-app with a servlet that will load some data from various property/text files into Hashtables (or classes extending HT), cache it using OSCache for say 48 hrs and service client requests.
Another application (which can be any application, the Utlity API shouldn't bother about it), lets call it client application, has a servlet that will send request to this API (say request for translating a word to another language). The API will search for the translation in the Hashtables and return it to the servlet if found (or an empty string if not found).
I am really not able to imagine the design part of it. My API should have abstraction so that any client API can use it. The API on the other hand should be something like a service (apart from usual java classes) that updates the data after the OSCache TTL expires automatically. Can anybody help me in this?
Thanks for your time ranchers..
[ December 01, 2003: Message edited by: Yash Sharma ]
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
You say you are writing a utility API, then why do you want to have a servlet on top of it ?? You can simply expose your APIs as a simple Java class and let any client call the methods.
If for whatever reason, you need to have a servlet on top of your utility API, then no problem. Any client can simply make a HTTPConnection to your servlet and get the response stream with the results.
Regards.
Yash Sharma
Ranch Hand

Joined: Jan 30, 2003
Posts: 61
Thanks for the reply. Actually I am envisaging a Servlet in the utility API because I need some sort of service that automatically reads the data from property/text files periodically (as per the TTL of OSCache) and has the Hashtables loaded in memory, ready to respond to the client Servlet.
I could have kept the hash data in a database but I want to avoid that. The data is not changing too frequently and is hence cached and updated only in say a week or so. The client Servlets would be given responses based on this cached data.
[ December 01, 2003: Message edited by: Yash Sharma ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
You can basically go 2 ways here.
First way is to write the servlet to take in HTTP requests (or whatever protocol) and act as a regular servlet would, returning the results using it's reqular PrintWriter.
Second way would have the servlet sitting there and acting as a server of its own, responding to requests in a custom protocol you need to design and passing back the results in whichever way is easiest for you. This is a bit more programming effort but a more flexible approach.


42
Yash Sharma
Ranch Hand

Joined: Jan 30, 2003
Posts: 61
Thanks again for the reply. There is one more query in my mind. I am aware of various frameworks like Struts or Cocoon. For the server-side Utility API that I want to make is there any free framework available. Obviously I am interested in a non-GUI type of framework since my API would not involve any GUI but would simply respond to client requests.
I hope I am not being stupid but perhaps I am asking something of a framework for the Business Logic Layer.
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Originally posted by Yash Sharma:
Thanks again for the reply. There is one more query in my mind. I am aware of various frameworks like Struts or Cocoon. For the server-side Utility API that I want to make is there any free framework available. Obviously I am interested in a non-GUI type of framework since my API would not involve any GUI but would simply respond to client requests.
I hope I am not being stupid but perhaps I am asking something of a framework for the Business Logic Layer.

I suggest for your requirement mentioned above, it simply would be easy to finish it off on your own. learning a framework and most importantly using it effectively will take some time. well, i dont know of any f/w that fits your requirement.
[ December 02, 2003: Message edited by: shankar vembu ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Servlet to Servlet