*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Inter Servlet Communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Inter Servlet Communication" Watch "Inter Servlet Communication" New topic
Author

Inter Servlet Communication

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
IS this same as forward and including a page.
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
It can be much more than that. I guess we can broadly classify the interservlet comm. into two categories. First, between servlets running under the same web context and secondly running under different web contexts as in a truly distributed environment.
Typically when we say servlets communicating with each other, it may imply the exchange of information via objects. Objects can be stored at different scopes like application, session and request using keys to retrieve them across servlets.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
how do servlets in distributed env communicate or share objects.
Why is the need for servlets in different web context to communicate.
If we do a J2ee project won't all the components be in one server.
Somehow can anyone explain it more clearly.?
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
I didn't get to work with servlets contacting each other from different web contexts, but i'm pretty sure such a thing exists. If you ask me under what scenario, the people who work full fledged on these things should come up with the situations. I'm also waiting to hear from someone on this.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
I didn't get to work with servlets contacting each other from different web contexts, but i'm pretty sure such a thing exists. If you ask me under what scenario, the people who work full fledged on these things should come up with the situations. I'm also waiting to hear from someone on this.
Trust me, it exists. I work for a large corporation and we have our site spread across many servers.
how do servlets in distributed env communicate or share objects.
There are lots of ways, but the two most important ways are using databases and EJBs. You can use serialized objects and a URLConnection to communicate between servlets or just RMI.
Why is the need for servlets in different web context to communicate.
If we do a J2ee project won't all the components be in one server.

Load balancing, failsafe issues (you don't want the whole site going down if just one server crashes), keeping logical sections of the site separated, mitigating risk when deploying new development, etc.

If we do a J2ee project won't all the components be in one server.

That's fine for a small site but isn't practical for a large enterprise operation. It does complicate matters though, because you could cross JVMs several times with a single request. That can make debugging tuff, but interesting. Also note that for a full J2EE project, you would have EJBs somewhere which lend themselves well to a distributed environment. That fact that they can easily be accessed remotely is one of their main selling points, along with built-in transaction management and container managed persistence.


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
Originally posted by Michael Morris:

Why is the need for servlets in different web context to communicate.
If we do a J2ee project won't all the components be in one server.

Load balancing, failsafe issues (you don't want the whole site going down if just one server crashes), keeping logical sections of the site separated, mitigating risk when deploying new development, etc.
[b]

Michael,
Can you please direct me to any resources on the web that talk about replicating sessions in the event of server crash, etc., so that the user would never feel any change, despite for some latency? I would appreciate your inputs.
Thanks.
 
jQuery in Action, 2nd edition
 
subject: Inter Servlet Communication