users@glassfish.java.net

RE: java.util.Vector cannot be cast to entity bean

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Sat, 17 Oct 2009 17:17:57 +0100

Hi,

 

Thank you for your reply. I managed to get things working.

When I change the useBean scopet to application or requestion-

 

<jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" />


 

But then the data I want to display is a null.

 

I am trying to establise why the data is a null. It looks like data is

not being forwarded from my servlet to my jsp. IN my servlet I have -

 

 


                               baleent=baleBeanRemote.findAllBales();
                               System.out.println(baleent);
                                HttpSession session = request.getSession();
                                  session.setAttribute("baleent",baleent);
                
                               //Choose which JSP for presentation
                                 RequestDispatcher dispatcher = getServletContext()
                                               .getRequestDispatcher("/Viewdisplayold.jsp");
                                 
                                 //forward data to the DiscountItemsj.jsp to present
                                //it to user
                                  dispatcher.forward(request, response);
                
                 
                      }catch(Exception ex){
   System.err.println("Can not access DB");
   }

 

SO shouldn't the useBean above pickt it up in the Viewdisplay.jsp?

 

What I'm I doing wrong?

 

eve
 
> Date: Sat, 17 Oct 2009 08:41:07 -0700
> From: hassan.schroeder_at_gmail.com
> To: users_at_glassfish.dev.java.net
> Subject: Re: java.util.Vector cannot be cast to entity bean
>
> On Fri, Oct 16, 2009 at 1:22 PM, Eve Pokua <gorgeous65_at_msn.com> wrote:
>
> > try{
> > //call the allbales method
> > baleent=baleBeanRemote.findAllBales();
>
> Wouldn't it be more readable/self-documenting if that was "bales" or
> "allBales" or something? Just sayin'...
>
> > <jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" />
>
> > java.lang.ClassCastException: java.util.Vector cannot be cast to
> > entityJB.Baleent
>
> Yep, so what does `baleBeanRemote.findAllBales()` return? Pretty
> obviously -- if it's meant to return *bales* plural, it's very likely to be
> a collection object of some kind. Like, say, a Vector ...
>
> FWIW,
> --
> Hassan Schroeder ------------------------ hassan.schroeder_at_gmail.com
> twitter: @hassan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                               
_________________________________________________________________
Download Messenger onto your mobile for free
http://clk.atdmt.com/UKM/go/174426567/direct/01/
--_708b9103-2480-49e3-814e-ae66068b2fbe_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hi,<BR>
&nbsp;<BR>
Thank you for your reply.&nbsp; I managed to get things working.<BR>
When I change the useBean scopet to application or requestion-<BR>
&nbsp;<BR>
&lt;jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" /&gt;<BR><BR>
&nbsp;<BR>
But then the data I want to display is a null.<BR>
&nbsp;<BR>
I am trying to establise why the data is a null.&nbsp; It looks like data is<BR>
not being forwarded from my servlet to my jsp. IN my servlet I have -<BR>
&nbsp;<BR>
&nbsp;<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; baleent=baleBeanRemote.findAllBales();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println(baleent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpSession session = request.getSession();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; session.setAttribute("baleent",baleent);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Choose which JSP for presentation<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RequestDispatcher dispatcher = getServletContext()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }catch(Exception ex){<BR>&nbsp;&nbsp;&nbsp;System.err.println("Can not access DB");<BR>&nbsp;&nbsp;&nbsp;}<BR>
&nbsp;<BR>
SO shouldn't the useBean above pickt it up in&nbsp;the Viewdisplay.jsp?<BR>
&nbsp;<BR>
What I'm I doing wrong?<BR>
&nbsp;<BR>
eve<BR>&nbsp;<BR>&gt; Date: Sat, 17 Oct 2009 08:41:07 -0700<BR>&gt; From: hassan.schroeder@gmail.com<BR>&gt; To: users@glassfish.dev.java.net<BR>&gt; Subject: Re: java.util.Vector cannot be cast to entity bean<BR>&gt; <BR>&gt; On Fri, Oct 16, 2009 at 1:22 PM, Eve Pokua &lt;gorgeous65@msn.com&gt; wrote:<BR>&gt; <BR>&gt; &gt; try{<BR>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //call the allbales method<BR>&gt; &gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; baleent=baleBeanRemote.findAllBales();<BR>&gt; <BR>&gt; Wouldn't it be more readable/self-documenting if that was "bales" or<BR>&gt; "allBales" or something? Just sayin'...<BR>&gt; <BR>&gt; &gt; &lt;jsp:useBean id="baleent" scope="session" class="entityJB.Baleent" /&gt;<BR>&gt; <BR>&gt; &gt; java.lang.ClassCastException: java.util.Vector cannot be cast to<BR>&gt; &gt; entityJB.Baleent<BR>&gt; <BR>&gt; Yep, so what does `baleBeanRemote.findAllBales()` return? Pretty<BR>&gt; obviously -- if it's meant to return *bales* plural, it's very likely to be<BR>&gt; a collection object of some kind. Like, say, a Vector ...<BR>&gt; <BR>&gt; FWIW,<BR>&gt; -- <BR>&gt; Hassan Schroeder ------------------------ hassan.schroeder@gmail.com<BR>&gt; twitter: @hassan<BR>&gt; <BR>&gt; ---------------------------------------------------------------------<BR>&gt; To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net<BR>&gt; For additional commands, e-mail: users-help@glassfish.dev.java.net<BR>&gt; <BR> <br /><hr />Download Messenger onto your mobile for free. <a href='http://clk.atdmt.com/UKM/go/174426567/direct/01/' target='_new'>Learn more.</a></body>
</html>
--_708b9103-2480-49e3-814e-ae66068b2fbe_--