Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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

ServletContext

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,
How one ServletContext can communicate with the another ServletContext.

thanks in advance
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are several ways.

What are you trying to acomplish?
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Each web application has one and only one ServletContext. There is no such thing as one ServletContext communicating with another ServletContext. This would be the same as one web app communicating with another web app. You can use the ServletContext to pass objects (and init parameters called context initialization parameters) between 2 Servlets that exist in the same web app.
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Ku:
There is no such thing as one ServletContext communicating with another ServletContext.



You are mistaken. But we'll wait until we find out what the OP is actually trying to do before commenting further.
 
thamara chempakam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

Each web application has one and only one ServletContext. thats right.
But how one ServletContext(one Web Application) communicate with another ServletContext (another web application).

thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again, there are several ways.
I'm not going to try to list them.

If you tell us what you're trying to accomplish, someone can probably suggest a good say to do it.
 
thamara chempakam
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers,

i have two web application (running on two different Tomcat). i want to call one method of wepApp1 from webApp2. how can it be possible?

thanks and regards
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Web applications don't have methods.

Without some details about what you're trying to accomplish, we can't give you details about how to do it.

Again, there are several ways for web applications to communicate with one another.
Some of them include:
  • RMI
  • HTTP Posts
  • Hyperlinks with querystrings.
  • Web services
  • Shared files
  • A shared database
  • JMS

  • There are more but those are the ones I can think of off the top of my head.
     
    thamara chempakam
    Greenhorn
    Posts: 20
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks Ben,

    The dirctory structure of webApp1 is given below


    In web2, instead of Manage.java i have a class offload.java which wants to call the Manage.method().
    how will it be possible

    [BPSouther: Added code tags]
    [ July 26, 2007: Message edited by: Ben Souther ]
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If this were my issue and there were a lot of them, I would look at a product like Apache Axis to expose these methods as webservices.

    If it were one or two, and they were fairly simple, I would probably just write a servlet that exposes the methods and then use either java.net.URLConnection or a library like Jakarta Commons httpclient to build the client on the other end.

    I'm not an expert on JMS or RMI but you might want to look into those as well.
     
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I know that webservice provides you the facility for the exposing the services outside.

    Is it not possible to communicate within web applications without going for webservices or any other external features but using Servlet's features Ben?

    I think it will make sense to use Servlet's features (like ServletContext etc) only for the interaction within the same web application. Is that right?

    Just to confirm my thought on the same.
     
    Ben Souther
    Sheriff
    Posts: 13411
    Firefox Browser VI Editor Redhat
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Raghavan Muthu:
    I know that webservice provides you the facility for the exposing the services outside.

    Is it not possible to communicate within web applications without going for webservices or any other external features but using Servlet's features Ben?

    I think it will make sense to use Servlet's features (like ServletContext etc) only for the interaction within the same web application. Is that right?

    Just to confirm my thought on the same.



    Yes, Tomcat (and most other servers, I assume) can be configured to allow some crossContext interaction.
    In this case, however, the original poster has already stated that the two applications are running on different instances of Tomcat.
    [ July 26, 2007: Message edited by: Ben Souther ]
     
    Raghavan Muthu
    Ranch Hand
    Posts: 3389
    Mac MySQL Database Tomcat Server
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    In case of interaction between the two applications on a different instances of Application Server, the only possible way to proceed is to rely on the external features like WebServices etc.

    Thank you Ben.
     
    You showed up just in time for the waffles! And this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    reply
      Bookmark Topic Watch Topic
    • New Topic