• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp not showing result in table form

 
kalpana sachan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check in the action to see if there are any results?
 
kalpana sachan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
yes. in action class i'm getting the correct result.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic