This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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
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 ]
Joined: Mar 04, 2002
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