You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by mel-hustler <ja...@yahoo.com> on 2007/09/28 11:19:32 UTC
Struts-Populating data in JSP
Hi,
I am new to struts.
I have retrieved the data in the ResultSet in the Action class, which gets
retrieved fine,
Now I want to display this data on the view.jsp page.
MyAction class is:
----------------------------------------------------------------------------------
public class ViewItemAction extends Action implements Serializable{
public ViewItemAction () {
System.out.println("Getting request Action 'View Item' Instantiated");
}
public ActionForward perform(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException, SQLException, Exception {
System.out.println("inside perform");
EnterRecpietHandler erh=new EnterRecpietHandler();
ResultSet rs=erh.getData();
java.util.List resultsList =new ArrayList();
System.out.println("Checkxx");
while ( rs.next()==true ){
ResultRecpietForm resultBean = new ResultRecpietForm();
resultBean.setItem(rs.getString("item"));
resultBean.setPrice(String.valueOf(rs.getFloat("price")));
resultsList.add(resultBean);
}
request.setAttribute("resultsList",resultsList);
return mapping.findForward("sucess");
}
}
--------------------------------------------------------------------------
"sucess" is mapped to view.jsp in strut-config-xml file
view.jsp is:
-------------------------------------------------------------------------
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<title>List</title>
</head>
<body>
<table cellspacing="3" cellpadding="3" border="1" width="500">
<tr>
<td colspan="4">Customer </td>
</tr>
<tr>
<td>Item</td>
<td>Price</td>
</tr>
<c:forEach var="result" items="${requestScope.resultsList}">
<tr>
<td>${result.item}</td>
<td>${result.price}</td>
</tr>
</c:forEach>
</table>
</body>
</html>
-----------------------------------------------------------------------------------
Any help is greatly appreciated.
If someone can tell, what is wrong with, and why I cannot get any data on
view.jsp it will be very nice.
Best Regards
Mel
--
View this message in context: http://www.nabble.com/Struts-Populating-data-in-JSP-tf4533318.html#a12937235
Sent from the Struts - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org
Re: Struts-Populating data in JSP
Posted by Antonio Petrelli <an...@gmail.com>.
2007/9/28, mel-hustler <ja...@yahoo.com>:
>
>
> Hi,
> I am new to struts.
Ask this kind of questions in the Struts Users mailing list:
http://struts.apache.org/mail.html
Anyway I notice that you are *very* new to Struts 1, so I suggest you to
read some tutorial:
http://struts.apache.org/1.3.8/userGuide/index.html
Antonio