wood burning stoves
The moose likes JSP and the fly likes app-to-app call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "app-to-app call" Watch "app-to-app call" New topic

app-to-app call

Juan Rolando Prieur-Reza
Ranch Hand

Joined: Jun 20, 2003
Posts: 237
Hello JSP experts, any advice on this JSP problem?
I have two JSP/servlet applications called “SimpleQuantity” and “DoWork”. DoWork wants to use a “quantity” generated and displayed by the SimpleQuantity app. I’m writing DoWork now and don’t want to modify or duplicate the code in the stand-alone SimpleQuantity app. DoWork will invoke the SimpleQuantity app via redirect (either to a new browser instance or to a frame target in the same browser; doesn’t matter?). SimpleQuantity fortunately stores its resulting “quantity” in “its” session object, as well as displaying it in its HTML output. I hope that DoWork can then get this “quantity” from the session object (when SimpleQuantity completes). I believe there is only one session object here because DoWork did a redirect to SimpleQuantity rather than forward.
My question(s):
1. Is this “the right” approach in the JSP world? Is there another “proper” way to seamlessly integrate such JSP applications without having to modify the existing app?
2. If “session” object might work, is there a way for DoWork to access the Application scope object or page scope of SimpleQuantity (to be cleaner and maintain good encapsulation)? There should be a clean ways for a JSP to “expose” just the vars intended to be used from other apps.
3. Is there a way for SimpleQuantity to "signal" DoWork when its done? (e.g. send an interrupt to wake up a thread for example?)
Thanks in advance for any advice. :roll:

Juan Rolando Prieur-Reza, M.S., LSSBB, SCEA, SCBCD, SCWCD, SCJP/1.6, IBM OOAD, SCSA
Phil Chuang
Ranch Hand

Joined: Feb 15, 2003
Posts: 251
Sounds like a job for the MVC pattern (model view controller). From your description of SimpleQuantity, you have the main business logic in your servlet. You should abstract it out so that all the logic is done in pure java, and have the servlet merely pass information along. That way you can re-use that code in any servlet as opposed to being tied down to one specific servlet.
kalpana Kumar
Ranch Hand

Joined: Jul 03, 2003
Posts: 65
I guess using Struts would be more useful in case U decide on with MVC approach..
Juan Rolando Prieur-Reza
Ranch Hand

Joined: Jun 20, 2003
Posts: 237
Thanks but the use of MVC or Struts is not applicable here. First, I don't have access to the software on the host where SimpleQuantity runs, as I indicated in my problem statement. Consider it a 3rd party application and all I know is that it stores a certain quantity in its session object. Presently, I am not tasked to re-architect this system. So the question is simple. To re-state the essence of the question:
Would a good JSP programmer write the DoWork application to access the "quantity" from the "shared" session object, as I have described? Or is there is smarter way, using JSP and Servlets only? (That does not involve re-architecting the two systems to run on a single host and rewrite it to use J2EE). Thanks again.
I agree. Here's the link: http://aspose.com/file-tools
subject: app-to-app call
jQuery in Action, 3rd edition