tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "laurent marot" <laurent.ma...@alliacom.com>
Subject sharing objects betweeen different contexts (Long)
Date Tue, 08 Jul 2003 19:20:38 GMT
Hi all,

I'm trying to create an object in a Jsp page in an application named

AppA and get it back in another page in AppB.

When i made a test with String="my data to share" everything works properly
but when i try to create

a User Objets (simple java class in MyPackage package) i get a Cast
Exception in the receiver page.

any idea to solve this problem?

thanks a lot.

Platform : tomcat 4.1.24 on windows2000 with JDK 1.4.1





/AppA/contextAUser.jsp page :

<%@ page import="java.util.*, myPackage.*"%>

<% out.println(session.getId());

String sessionid = session.getId();

String datas="my datas to share";

User user = new User("myName", "myRole");

ServletContext context=session.getServletContext();

Hashtable shareddata =

(Hashtable)context.getAttribute("user");

if (shareddata==null) shareddata =new Hashtable();

//shareddata.put(sessionid, datas);

shareddata.put(sessionid,user);

context.setAttribute("user", shareddata);%>

<BR><a href="/AppB/contextBUser.jsp?jsessionid=<%=session.getId()%>"
target="blank">Got to B appplication</a><BR>

----------------------------------------------------------------------------
-----

/AppB/contextBUesr.jsp page :

<%@ page import="java.util.*,myPackage.*"%>

<% String ssosessionid=request.getParameter("jsessionid");

out.println(session.getId());

ServletContext context=session.getServletContext();

String SignonContext="/wisd";

ServletContext ssocontext = context.getContext(SignonContext);

if (ssocontext==null) out.println("no context !");

String userroles = null;User user = null;

Hashtable shareddata = null;shareddata =
(Hashtable)ssocontext.getAttribute("user");

if (shareddata!=null) {

//userroles = (String)shareddata.get(ssosessionid);

user = (User)shareddata.get(ssosessionid);

out.println(user.getUserId());

}

else out.println("no context !");%>

----------------------------------------------------------------------------
---------------------------

org.apache.jasper.JasperException

at

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2

48)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application

FilterChain.java:247)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh

ain.java:193)

at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja

va:260)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja

va:191)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)

at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180

)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.

java:170)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172

)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java

:174)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)

at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)

at

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne

ction(Http11Protocol.java:386)

at

org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)

at

org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav

a:530)

at java.lang.Thread.run(Thread.java:536)

cause mère

java.lang.ClassCastException

at org.apache.jsp.contextBUser_jsp._jspService(contextBUser_jsp.java:60)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:2

04)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

at

org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application

FilterChain.java:247)

at

org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh

ain.java:193)

at

org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja

va:260)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja

va:191)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)

at

org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180

)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.

java:170)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172

)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:641)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at

org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java

:174)

at

org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok

eNext(StandardPipeline.java:643)

at

org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)

at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)

at

org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:432)

at

org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne

ction(Http11Protocol.java:386)

at

org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)

at

org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav

a:530)

at java.lang.Thread.run(Thread.java:536)


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message