• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java.lang.ClassCastException

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am getting java.lang.ClassCastException .
IN the follwing line . in a jsp page .
ResultBean rb=(ResultBean)request.getAttribute("resultdata");

IN the servlet code
ResultBean rb= new ResultBean();
rb.setaName(Acc.getName());
rb.setaIATA(Acc.getIATA());
request.setAttribute("resultdata", rb);
The Exception :

java.lang.ClassCastException
at jsp_servlet.__results._jspService(__results.java:131)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:305)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispat
herImpl.java:594)
at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispat
herImpl.java:409)
at CntlrServlet.doGet(CntlrServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
ServletStubImpl.java:1053)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:387)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
l.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
.run(WebAppServletContext.java:6310)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
Subject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
18)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
vletContext.java:3622)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
l.java:2569)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)


Thanks,
Tirthankar
 
Ranch Hand
Posts: 237
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tirthankar,

I doubt that the attribute is not being set for some reason. Why don't you add logs in your servlet to see if the attribute is really getting set? Additionally, you can test for null before doing the cast in your JSP.

Give us an update,
Saket
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check __results.java line 131 to see if any Class Cast error.
 
reply
    Bookmark Topic Watch Topic
  • New Topic