Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calling Java Servlet from another java class

 
Mike Cunningham
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm needing to call a java servlet 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,

Mike
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Bourdeaux
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Mark
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A simple URL class in your application may be able to do the trick. Using URL class you can connect to server and get the page that the servlet sends out and process the page in your application.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic