aspose file tools*
The moose likes Servlets and the fly likes Global settings in JSPs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Global settings in JSPs" Watch "Global settings in JSPs" New topic
Author

Global settings in JSPs

Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi,
I have a requirement for a distributed web application to share the objects across VMs
Since there is one instance of application object per VM, the objects which I store in the object, is not available for the servlets/JSP for the other VM
How do I go about with this problem?
Thanks in advance,
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 25, 2001).]


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
Desai, you ask all the hard questions
Do you know for sure that these objects are not available in the other VM's? Or are you making that assumption? The servlet spec (section 7.7.2) says that if a webapp is marked as distributable in the deployment descriptor, all objects bound an HTTP session must be serializable, and that they can be moved from one VM to another and deserialized.
But you didn't ask about sessions, you asked about the servlet context (application) object. The spec is not clear on whether objects bound with setAttribute must be serializable and whether they are automatically moved to the other VM when the servlet is activated. The best you can do is test (if you haven't already) after making sure you have specified <distributable/> in the web.xml file.
------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
Website: http://www.philhanna.com


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Phil,
Thank you for your response.
After having marked my web application as distributable in the web.xml file, I thought the JVM would share the data at the application implicit object Level.But it seems, that each JVM has its own copy of application implicit objects, i.e. there is exaxtly one instance of the servlet per JVM.
Hence shared access to to the data is not possible in the application scope.Hope I am correct!!!
If I am correct, then the only alternative that I can think of for sharing some resource between JVM's is through an external mechanism, such as a directory server accessed through JNDI, or a Database, or a file that would be available for all the servers.
Please let me know your opinion on this.
Regards

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56

  5. [This message has been edited by Desai Sandeep (edited April 26, 2001).]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Desai Sandeep:
[...]Hence shared access to to the data is not possible in the application scope.

That's my understanding too: in a clustered server, only session-scoped objects are shared between JVMs in the cluster. (I would be happy to be corrected though).
If I am correct, then the only alternative that I can think of for sharing some resource between JVM's is through an external mechanism, such as a directory server accessed through JNDI, or a Database, or a file that would be available for all the servers.

If the shared data is updated regularly and you value both scalability and sanity, forget about the file. JNDI (for non- persistent or immutable data) and a database (for persistent data) are both appropriate. For some problems, using message queues to broadcast updates of shared data could be an idea.
- Peter
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Peter,
Thanks for your response.

If the shared data is updated regularly and you value both scalability and sanity, forget about the file. JNDI (for non- persistent or immutable data) and a database (for persistent data) are both appropriate. For some problems, using message queues to broadcast updates of shared data could be an idea

Yes, the JNDI and DB storage seems to be better options than considering writing serialized objects in the file.However, I am not sure how this could be done using message queues.Are you hinting JMS as a solution?
Thanks in advance,

------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Desai Sandeep:
However, I am not sure how this could be done using message queues.Are you hinting JMS as a solution?

JMS can conceivably be part a solution. If you are holding data in an application-scoped cache, updates happen regularly but not excessively so, and if it is no problem that cached data can be stale for a short period of time, then you could use JMS to distribute the updates to the servers in the cluster.
That's a whole lot of "if"s. These issues don't have a single clear-cut answer. The solution you choose will be determined by whether the data is coming from persistent storage, if and how often it is updated, if and how long data may be stale, how bulky the data is, how much time it would cost to reconstruct it or reread it from persistent storage, and the facilities and performance characteristics available on your deployment platform.
- Peter
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi Peter,
It seems like we need to some more research on this.From your posts I infer, there are no definite bench marks as to what would be the Best Solution to choose from JNDI, persistent storage or Message queues.Looks like every solution has its own advantages and disadvantages, and it has to be carefully selected based on the requirements.Also, it seems to be deployment platform specific.
Lots of issues to take care of!!
Thanks once again.
Regards,


------------------
Sandeep Desai
vgdesai@bom3.vsnl.net.in

  1. Sun Certified Java Programmer Scored 93 per cent
  2. Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java Scored 56 out of 59
  3. IBM Enterprise Connectivity with J2EE Scored 72 per cent
  4. Enterprise Development on the Oracle Internet Platform Scored 44 out of 56
 
jQuery in Action, 2nd edition
 
subject: Global settings in JSPs