Assign value to HTML textbox from JSP

Posted by prakash_d22 on Stack Overflow See other posts from Stack Overflow or by prakash_d22
Published on 2012-09-15T09:10:02Z Indexed on 2012/09/15 9:37 UTC
Read the original article Hit count: 177

Filed under:
|
|
|

Hello I am creating a web page to add some information about given product.I need to enter id,name,description and image as information.I need the id to be auto generated.I am using jsp and database as access.I am fetching the count(*)+1 value from database and assigning to my html text box but its showing as null.can i get some help?

Code:

<body>
<%@page import="java.sql.*"%>
<%! String no; %>
<%
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:pd");
ResultSet rs = null;
Statement st = con.createStatement();
String sql = ("select count(*)+1 from products");
st.executeUpdate(sql);
while (rs.next()) { 
no=rs.getString("count(*)+1");
}
rs.close();
st.close();
con.close();
}
catch(Exception e){}
%> 
<Form name='Form1' action="productcode.jsp" method="post">
<table width="1024" border="0">
  <tr>
    <td width="10">&nbsp;</td>
    <td width="126">Add Product: </td>
    <td width="277">&nbsp;</td>
    <td width="583">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>Product Id:</td>
    <td><label>
      <input type="text" name="id" value="<%= no%>"/>
    </label></td>
    <td>&nbsp;</td> 
.... and so on

© Stack Overflow or respective owner

Related posts about html

Related posts about sql