wood burning stoves 2.0*
The moose likes Struts and the fly likes jsp not showing result in table form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "jsp not showing result in table form" Watch "jsp not showing result in table form" New topic
Author

jsp not showing result in table form

kalpana sachan
Greenhorn

Joined: May 11, 2010
Posts: 2
Hi, I want to fetch data from the database and trying to display them in table form. Please tell me where is the problem.


TransactionAction.java::

public class TransactionAction extends Action {

public ActionForward execute(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response) {

List<Productinterest> pi = new ArrayList<Productinterest>();
Productinterest prodint;

String driver = "com.mysql.jdbc.Driver";
String connectionURL="jdbc:mysql://192.168.1.19:3306/bizuser?autoReconnect=true";
String user = "bizuser";
String pwd = "password";
String QueryString = null;
Statement statement = null;
ResultSet rs = null;
Connection con = null;
try {
Class.forName(driver);
if(con==null || con.isClosed()){
con = DriverManager.getConnection(connectionURL, user, pwd);
statement = con.createStatement();
String id = request.getParameter("id");
if(id!=null || id=="" & con!=null){

QueryString= "select pi.buyer, pi.unitprice, pi.quantity,pi.transactionstatus from productinterest pi where pi.transactionid= '"+id+"'";
rs = statement.executeQuery(QueryString);

if (rs!=null){
while (rs.next()) {
prodint=new Productinterest();
prodint.setBuyer(rs.getString(1));
prodint.setUnitprice(rs.getFloat(2));
prodint.setQuantity(rs.getInt(3));
prodint.setTransactionstatus(rs.getString(4));

pi.add(prodint);
}
}

rs.close();
statement.close();
con.close();
}
}
} catch (Exception ex) {
ex.printStackTrace();
}

request.setAttribute("plistname",pi);

return mapping.findForward("success");
}
}

========================================
accountsuccess.jsp:::

<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-logic.tld" prefix="logic" %>
<html>
<body><center></br></br>
<form action="/baTransaction">

<table>

<tr>
<th>Buyer</th>
<th>Price</th>
<th>Quantity</th>
<th>Status</th>
</tr>
<tr>
<td>
<logic:iterate id="product" name="plistname">
<bean:write name="product" property="buyer">
</logic:iterate>
</td>
</tr>
</table>

</form>
</body>
</html>
===================================
struts-config.xml

<action path="/baTransaction" type="com.bookadda.account.TransactionAction" name="homeForm" scope="request">
<forward name="success" path="/WEB-INF/jsp/general/accountsuccess.jsp"></forward>

</action>


on executing this no error is coming but it is not displaying any result. only showing table headers
Buyer Price Quantity Status



David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read.

You can edit your post by using the button.

And welcome to JavaRanch!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Did you check in the action to see if there are any results?
kalpana sachan
Greenhorn

Joined: May 11, 2010
Posts: 2
Hi,
yes. in action class i'm getting the correct result.
Vidya Gupta
Ranch Hand

Joined: Mar 18, 2012
Posts: 98

.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp not showing result in table form
 
Similar Threads
Only for one data in the text box
Cannot find bean in any scope
how do i use html:select to forward to different pages?
JSP DataBase Connection
logic:iterate pls any body help me