I'm needing to call a javaservlet from a seperate java class using a PL/SQL function for an application residing on Oracle Application Server. What steps should I keep in mind in order to make the code thread-safe? I understand that I should avoid instance variables. Also, make any variables whose values remain constant as 'final'. So far, I've only been able to call java methods from PL/SQL functions that are defined as 'public' & 'static'. I don't want to impliment the single-threaded model since this application will be fairly high volume.
Thanks in advance,
Author and all-around good cowpoke
Joined: Mar 22, 2000
The only way to get information out of a servlet based web application is by creating a request and getting a response. Typically with a HttpURLConnection or a toolkit like HttpClient that manages a HttpURLConnection. If you have to write the servlet, then yes, all the usual thread safety considerations apply. This sounds sort of like a "Web Service" - is that what you have in mind? Bill
I don't want to impliment the single-threaded model
The SingleThreadModel has been depreciated anyway. It turned out to be remarkable thread unsafe, especially when it came to sessions.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
Originally posted by Paul Bourdeaux: The SingleThreadModel has been depreciated anyway. It turned out to be remarkable thread unsafe, especially when it came to sessions.
It used to be appreciated, but not anymore.
If this is a Web Service, wouldn't you call it using an HttpConnection. If it not a web service, I am assuming that the call would not be to doPost, etc... And if my assumption is correct, I highly recommend a refactor being done to remove the shared code from the Servlet into a Plain Old Java Object.