Forums
This topic is locked
Plz help me in JSP tutorial
22 Nov 2005 06:15:55 Ngoc Lam posted:
Hi, can anyone help me in this JSP tutorial. I want to retrieve data from my database and put <b>into the option button</b>. In this tutorial, I need to retrived the status of the light from database. If the status is On ==> check the On button. If status is 'OFF' ==> checked the Off button.<pre id=code><font face=courier size=2 id=code><%@ page import="java.sql.*" %>
<jsp:useBean id="dbselect" class="database.dbSelect" scope="session"/>
<jsp:useBean id="cart" scope="session" class="database.ShoppingCart" />
<!-- Add an HTML table to format the results --><style type="text/css">
<!--
body {
background-color: #000000;
}
body,td,th {
color: #FFFFFF;
}
.style2 {color: #CCCCCC}
.style3 {color: #FF00FF}
.style4 {
color: #66CCFF;
font-weight: bold;
}
-->
</style>
Welcome, <br>
<center>
<h1 class="style3">Home Controller</h1><br>
Today is <%= new java.util.Date()%>
</center>
<frame>
<TABLE BORDER="1" width ="400" cellspacing="0" cellpadding = "2" align ="center">
<TR>
<TH>Location</TH>
<TH>Device</TH>
<TH>Status</TH>
</TR>
<%
String query = "SELECT * FROM Controller";
dbselect.rs = dbselect.executeQuery(query);
while ( (dbselect.rs).next() ) {
String device = dbselect.rs.getString("Device"
String location= dbselect.rs.getString("Location"
String status = dbselect.rs.getString("Status"
%>
<TR><form action="MyController.jsp" method="post">
<TD><%= location %></TD>
<TD><%= device %> </TD>
<TD> <input type="hidden" name="status" value= "<%= status %>" >
<input type="radio" name="button1" value="ON" >ON <input type="radio" name="button2" value="OFF">OFF</TD>
</form>
</TR>
<%
}
%>
</TABLE>
<p>
<center><input type="submit" name="ChangeStatus" value="Save Change"> <input type="Reset" name="Reset" value="Don't Save"> </center></p>
</frame>
<br>
<hr color=#a0cfeb>
<br>
<center>
<span class="style2">Copyright </span><span class="style4"> </span> 2005
</center>
</font id=code></pre id=code>