You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by shreya_2008 <ga...@yahoo.co.in> on 2008/02/22 11:50:22 UTC

Struts-basic-display search results in jsp

Hii,
I am a beginner in struts..I want to retrieve few records from database
and display in jsp page.First i tried assuming only one record is returned 
by the query..
Below is what i wrote in action.
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(query);
if(rs.next())
{
searchForm.setFlightno(rs.getString(1));
searchForm.setSource(rs.getString(2));
searchForm.setDestination(rs.getString(3));
searchForm.setDay(rs.getString(4));
searchForm.setDeptime(rs.getString(5));
searchForm.setArrtime(rs.getString(6));
searchForm.setNoofseats(rs.getString(7));
searchForm.setDate(date);
}
I populate the properties of bean so that i can print them in jsp..
Search Results 
    <bean:write name="searchForm" property="flightno"/><br>
<bean:write name="searchForm" property="source"/><br/>
 <bean:write name="searchForm" property="destination"/><br>
 <bean:write name="searchForm" property="day"/><br>
 <bean:write name="searchForm" property="deptime"/><br>
 <bean:write name="searchForm" property="arrtime"/><br>
 <bean:write name="searchForm" property="noofseats"/><br>
 <bean:write name="searchForm" property="date"/><br>


But the problem is I am not getting how to deal with multiple records.
Of course we store them in array but is that the correct method?
How such multiple instances form properties can be used and how can i print
them in jsp?
Ya there is logic iterator and all but where and how should i put the db
query result.
I know its a basic thing to be known but just not getting any idea..
Please help me.........
 

-- 
View this message in context: http://www.nabble.com/Struts-basic-display-search-results-in-jsp-tp15631512p15631512.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts-basic-display search results in jsp

Posted by shreya_2008 <ga...@yahoo.co.in>.
Yeah i know i am somewhere in the mid of chaos.Let me try..Thanks...
-- 
View this message in context: http://www.nabble.com/Struts-basic-display-search-results-in-jsp-tp15631512p15632075.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: Struts-basic-display search results in jsp

Posted by Antonio Petrelli <an...@gmail.com>.
2008/2/22, shreya_2008 <ga...@yahoo.co.in>:
>
> Below is what i wrote in action.
> Statement stmt=con.createStatement();



Err... a statement creation in an action? You'd better read some theory
before :-)

But the problem is I am not getting how to deal with multiple records.
> Of course we store them in array but is that the correct method?



Array, collection, whatever you want.

How such multiple instances form properties can be used and how can i print
> them in jsp?


<c:forEach>, <logic:iterate>, choose your poison :-)

Ya there is logic iterator and all but where and how should i put the db
> query result.



Create beans from the resultset and put them in a list.

But, again, I think that you should read a tutorial or a book. Programming
without a guide will lead you to write a pile of crap.

Antonio