Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with using multiple queries in single jsp page

 
sravya perumahanti
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please TellTheDetails--we have no idea what code you're using, what error you're getting, etc. ItDoesntWorkIsUseless.
 
Sam Deka
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following code in place of line no 24 -
ResultSet rs2 = st.executeQuery("select * from bulb where watts='"+bulbwatts+"'");
 
Sam Deka
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the following code in place of line no 24 -
ResultSet rs2 = st.executeQuery("select * from bulb where watts='"+bulbwatts+"'");
 
Sam Deka
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You haven't defined the string bulbwatts anywhere in your jsp..1st define the string bulbwatts as
String bulbwatts=request.getParameter("bulbwatts");
And then Try the following code in place of line no 24 -
ResultSet rs2 = st.executeQuery("select * from bulb where watts='"+bulbwatts+"'");
This must work..and do let me know
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam Deka wrote:This must work..and do let me know


The original post was over 4 years ago, so you shouldn't expect a response from the original poster!
 
Sam Deka
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Haha..i forgot to notice dat..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic