OK here is my code. How do I format the UnitPrice into a dollarformat?
<html>
<head>
<title>Database QRY</title>
</head>
<%@ page import="java.sql.*" %>
<body>
<table align="center" width="100%" border="1">
<th colspan="3" align="center">Products</th>
<tr>
<td><strong>Product Name</strong></td>
<td><strong>Unit Price</strong></td>
<td><strong>Units In Stock</strong></td>
</tr>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection get_products =
DriverManager.getConnection("jdbc:odbc:happytoad");
Statement stmt = get_products.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Products order by
ProductName");
while (rs.next())
{
String ProductName = rs.getString("ProductName");
String UnitPrice = rs.getString("UnitPrice");
String UnitsInStock = rs.getString("UnitsInStock");
out.print ("<tr>");
out.print ("<td>" + ProductName + "</td>");
out.print ("<td>" + UnitPrice + "</td>");
out.print ("<td>" + UnitsInStock + "</td>");
out.print ("</tr>");
}
get_products.close();
%>
</table>
</body>
</html>
Thanks,
Rich
-----Original Message-----
From: Christophe Coenraets [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 03, 2001 11:41 AM
To: JRun-Talk
Subject: RE: RS Formating
Use the formatting classes in java.text, for example java.text.NumberFormat.
Here is an example:
<%
java.text.NumberFormat nf =
java.text.NumberFormat.getCurrencyInstance();
// your sql stuff here
while (rs.next()) {
%>
<%= nf.format(rs.getDouble("price")) %>
<%
}
%>
This is also a great opportunity for creating a custom tag.
Christophe
-----Original Message-----
From: Rich Tretola
To: JRun-Talk
Sent: 9/3/2001 9:33 AM
Subject: RS Formating
How do I format a result set in JSP?
dolarformat, numberformat, dateformat, etc.?
Thanks,
Rich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists