File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes distributable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "distributable" Watch "distributable" New topic


Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have come accross this word number of times and I would like to clarify what I am thinking.
So if my web application is distributable(say in 2 machines)
similarly in machine 2 I have the same directory structure. ie
am I correct??? is this what is distributable ???
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
"Distributable" refers to the ability to run a single servlet container on multiple JVMs and even multiple machines. This gives you better scalability (just add more machines) and failover (if a machine dies, the others can take over).
The crucial difference between a distributed container and just running multiple ordinary containers is that a distributed container will have some mechanism to share HTTP sessions between the machines. For example, it may serialize the session and store it into a shared database.
I said "serialize". This is an important point in a distributable web application. When you mark a web-app as "distributable", all objects you store in the HttpSession must be serializable. Otherwise, the container can't do its distribution magic. You must also not use any techniques that break in a distributed container; for example, any instance of the Singleton pattern is potentially suspect as each JVM will get its own copy of the "Singleton". Well, most attempts at implementing Singletons in web containers are broken anyway, with class reloading and all that.
- Peter
Tariq Dweik

Joined: Aug 19, 2001
Posts: 20
Hi all
can anyone give an example on how to setup a distributable webapp in tomcat
Thanks in advance

Tariq Dweik
R K Singh
Ranch Hand

Joined: Oct 15, 2001
Posts: 5382
Originally posted by Peter den Haan:

- Peter

Thanks Peter

"Thanks to Indian media who has over the period of time swiped out intellectual taste from mass Indian population." - Chetan Parekh
Jim Bertorelli
Ranch Hand

Joined: Nov 28, 2001
Posts: 136
Just one minor correction to what Peter said. Sessions are not actually shared accross multiple JVMs. They can, however, be moved across multiple JVMs.
The point is, an HttpSession will be available only on one JVM at a time (so no sharing since only one JVM has exclusive access to the session). And all the requests belonging to that session will be serviced by that JVM. In case of failover or load balancing, the clustor manager can "move" this session to another server.
This is in contrast with the non-default servlet contexts, where each JVM has it's own copy of the the ServletContext. In this case also there is no sharing because each JVM has exclusive access to it's own copy.
I agree. Here's the link:
subject: distributable
It's not a secret anymore!