2 Replies Latest reply on Dec 13, 2006 12:28 AM by weiming chen

    display data

    weiming chen Newbie

      Hi, I have a problem with displaying data on jsp page. It is similar to the TrailBlazers and did work before by the way. Wish anyone give me some helps, thanks.

      The method in javabean is:

      public Collection getUser(){
      String oql = "select u from UserCredentialsEntity u";

      return em.createQuery(oql).getResultList();
      }

      The code in jsp page is:

      <%
      Collection people = aUser.getUser();
      for(Iterator iter = people.iterator(); iter.hasNext();){
      UserCredentialsEntity user = (UserCredentialsEntity)iter.next();
      %>
      Username: <%=user.getUsername() %>
      <%
      }
      %>

      The error message is:
      org.apache.jasper.JasperException: Exception in JSP: /test.jsp:29

      26: <%
      27: Collection people = aUser.getUser();
      28: for(Iterator iter = people.iterator(); iter.hasNext();){
      29: UserCredentialsEntity user = (UserCredentialsEntity)iter.next();
      30: %>
      31: Username: <%=user.getUsername() %>
      32: <%


      Stacktrace:
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

      root cause

      java.lang.ClassCastException: com.SurveyMaker.ejb.entity.UserCredentialsEntity
      org.apache.jsp.test_jsp._jspService(test_jsp.java:76)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)