Problem with passing a collection object from servlet to jsp
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Raymond_Wee
Posted On:   Monday, March 18, 2002 11:20 PM

Hi! I have a problem with regards to passing a collection object from an action servlet to a jsp using struts. In my perform function I passed a collection object using setAttribute. Here's a code snippet of my perform function: timecardSQL timesql = new timecardSQL(con); Collection col = timesql.findAll(); System.out.println(BeanNames.TIME_LIST); req.setAttribute("timeList", col); return mapping.findForward("success"); for my jsp page, I tried to retrieve it using it produced a "cannot find bean timeList on scope request" error. Why is that? I can't figure it out so I tried using jsp code <%   More>>

Hi!

I have a problem with regards to passing a collection object from an action servlet to a jsp using struts.
In my perform function I passed a collection object using setAttribute.

Here's a code snippet of my perform function:

timecardSQL timesql = new timecardSQL(con);
Collection col = timesql.findAll();
System.out.println(BeanNames.TIME_LIST);
req.setAttribute("timeList", col);
return mapping.findForward("success");

for my jsp page, I tried to retrieve it using



it produced a "cannot find bean timeList on scope request" error. Why is that?

I can't figure it out so I tried using jsp code

<%
Collection col = (Collection) request.getAttribute("timeList");
if (col == null)
out.println("null");
else
out.println("not null");
%>

this time I get a attribute has no value error.

Please help, thanks!

Raymond

   <<Less

Re: Problem with passing a collection object from servlet to jsp

Posted By:   Ping_Long  
Posted On:   Wednesday, March 20, 2002 09:17 AM

I have no trouble passing collection. I used the folloing :

" scope="request" type="webtm.database.timecard.timeCardCOLS">
section fk :<%=CreditInfo.getXXX()%>






The important thing is that make sure the object you put into collection must match type you define inside
Hope it works for you.




Ping
About | Sitemap | Contact