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 session in distributed web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "session in distributed web application" Watch "session in distributed web application" New topic

session in distributed web application

xiaoma wang
Ranch Hand

Joined: Mar 04, 2002
Posts: 74
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
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
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

Joined: Mar 04, 2002
Posts: 74
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
I agree. Here's the link:
subject: session in distributed web application
It's not a secret anymore!