• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

app-to-app call

 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
john
 
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess using Struts would be more useful in case U decide on with MVC approach..
 
Juan Rolando Prieur-Reza
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
If you believe you can tell me what to think, I believe I can tell you where to go. Go read this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic