GeeCON Prague 2014*
The moose likes JSP and the fly likes Problem with using multiple queries in single jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Problem with using multiple queries in single jsp page" Watch "Problem with using multiple queries in single jsp page" New topic
Author

Problem with using multiple queries in single jsp page

sravya perumahanti
Greenhorn

Joined: Jun 06, 2010
Posts: 1

Thanks for your reply sir.
this is my code-

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<body>
<center>
<form>
<table border="0">
<tr> <td> bulbtype </td>
<td> <input type="text" name="bulbtype"></td> </tr>
<tr> <td> bulbwatts </td>
<td> <input type="text" name="bulbwatts">
<input type="submit"/></td>
</tr>

<%
String bulbtype=request.getParameter("bulbtype");

String bulbname=request.getParameter("bulbname");
Class.forName("oracle.jdbc.OracleDriver").newInstance();
String connectionURL = "jdbcracle:thin:@127.0.0.1:1521:XE";
Connection conn = DriverManager.getConnection(connectionURL,"system","sravya");

Statement stmt=conn.createStatement();
Statement st=conn.createStatement();
ResultSet rs1 = stmt.executeQuery("select * from bulb where type="+bulbtype);
ResultSet rs2 = st.executeQuery("select * from bulb where watts="+bulbwatts);
%>
<%while(rs1.next()){%>
<tr> <td>name1</td>
<td> <input type="text" value="<%=rs1.getString("name")%>"></td> </tr>
<%}%>

<%while(rs2.next()){%>
<tr> <td>name2</td>
<td> <input type="text" value="<%=rs2.getString("name")%>"></td> </tr>

<%}%>

</table>
</form>
</center>
</body>
</html>


Im getting this error:

An error occurred at line: 24 in the jsp file: /bulb1.jsp
bulbwatts cannot be resolved
21: Statement stmt=conn.createStatement();
22: Statement st=conn.createStatement();
23: ResultSet rs1 = stmt.executeQuery("select * from bulb where type="+bulbtype);
24: ResultSet rs2 = st.executeQuery("select * from bulb where watts="+bulbwatts);
25: %>
26: <%while(rs1.next()){%>
27: <tr> <td>name1</td>


David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Please TellTheDetails--we have no idea what code you're using, what error you're getting, etc. ItDoesntWorkIsUseless.
 
 
subject: Problem with using multiple queries in single jsp page