Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session in distributed web application

 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, everybody:
Following is adapted from Sun Servlet's spec:
"if a servlet uses the RequestDispatcher to call a servlet in another web application, any sessions
created for and visible to the callee servlet must be different from those visible to the calling servlet."
My understanding is that the callee servlet is still in a session, which is a different from the original. But how i can get the attribute value from the new session? Since the attributes may never be shared between contexts...
Pls tell me sth about it. Thanks in advance!
Xiaoma Wang
 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ServletRequest object remains the same, so you can bind whatever needs to be shared as an attribute.
Don't get your hopes up too high though; while this works fine for built-in Java classes, if you're thinking about sharing your own classes you are bound to run into classloader problems -- each web-application will have its own classes in WEB-INF/lib & WEB-INF/classes, and the JVM considers them to be different even if they are in fact exactly the same.
You can get around this by deploying shared classes in the application server's lib directory (or in java/jre/lib/ext). But that means you can no longer fully package your applications in a WAR. You might be able to fiddle something using an EAR deployment but I'm not sure -- I'd need to check -- this is out of scope for the exam anyway
- Peter
[ May 20, 2002: Message edited by: Peter den Haan ]
 
xiaoma wang
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Peter. Your reply is always wonderful!
As per the objects needed in the distributed application, Sun's specification advise to put them in the EJB and database server to make them avalilable.
Xiaoyi Wamg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic