Prepare for your Next Interview
This is a discussion on My jsp program with combo error within the JSP forums, part of the Web Development category; I have a logical error here like that in jsp. My JSP program is like that. I couldn't extract the data from the database. I want to extract the ...
|
|||
|
My jsp program with combo error
I have a logical error here like that in jsp.
My JSP program is like that. I couldn't extract the data from the database. I want to extract the Department name then put the combo box in jsp program. I want to do like that. But can't. pls help me and suggest me. <%@ page language="java" import="java.sql.*, java.io.*" %> <% Connection con=null; try { String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String connectionUrl = "jdbc:sqlserver://localhost:1433;" + "databaseName=Raffles;user=sa;password=raffles;"; Class.forName(driver); con = DriverManager.getConnection(connectionUrl); Statement statement = con.createStatement(); ResultSet rs = statement.executeQuery("SELECT * FROM RaffleDept"); %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css"> <!-- .style1 {font-family: "Times New Roman"} .style6 { color: #FFFFFF; font-size: 27px; font-weight: bold; } body { background-color:#A6C9FD; } --> </style> <style type="text/css"> <!-- A.ssmItems:link {color:black;text-decoration:none;} A.ssmItems:hover {color:black;text-decoration:none;} A.ssmItems:active {color:black;text-decoration:none;} A.ssmItems:visited {color:black;text-decoration:none;} //.style7 {color: #FF0000} .style7 {color: #FF0000} .style8 {font-size: 27px; color: #FFFFFF;} --> </style> <SCRIPT SRC="Scripts/ssm.js" language="JavaScript1.2"> //Dynamic-FX slide in menu v6.5 (By maXimus, http://maximus.ravecore.com/) //Updated July 8th, 03' for doctype bug //For full source, and 100's more DHTML scripts, visit Dynamic Drive DHTML(dynamic html) & JavaScript code library </SCRIPT> </head> <body> <form method="post" name="RafflesUsers" class="style1" action="RafflesVessel.jsp"> <table width="1246" height="180" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="1246" height="161" valign="top"><img src="images/Banner.jpg" width="1246" height="184"> </td> </tr> </table> <!-- Banner Group--> <table width="1245" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutDefaultTable--> <tr> <td height="250" valign="middle"> <fieldset class="style1" style="border-color:#418BFA; border-width:thin"> <table width="668" height="211" border="0" cellspacing="3"> <tr> <td width="86">Vessel Name </td> <td width="569"><input name="txtvessel" type="text" id="txtvessel" size="60"></td> </tr> <tr> <td>Dept Name </td> <td> <select name="cbodeptname" id="cbodeptname"> <% while ( rs.next() ) { %> <option value= <%= rs.getString("DeptName")%>></option> <% } rs.close(); } catch (Exception e) { e.printStackTrace(); } finally { try { if ( con != null ) { con.close(); } } catch (SQLException sqle) { out.println(sqle.getMessage()); } } %> </select> </td> </tr> <tr> <td>Remarks</td> <td><textarea name="txtremark" id="txtremark"></textarea></td> </tr> <tr> <td height="62"> </td> <td> <div align="left"> <input type="submit" name="Submit" value="Submit"> </div></td></tr> </table> </fieldset></td> </tr> </table> </form> </body> </html> |
| Sponsored Links |
|
|||
|
Re: My jsp program with combo error
Here I use oracle database.I have a dbConnection.jsp file.I include that file in my current jsp page.say my current jsp page name is Test.jsp.In this page I fetch Qualification from database and display it in combo box.
<%@include file="dbConnection.jsp"%> <html> <head> <title>Test Page</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <form name="form1" method="post" action=""> <table width="100%" border="0"> <tr> <td width="38%"> <div align="right"><b>Qualification </b></div> </td> <td width="2%"> </td> <% String sql="select QUALIFICATION from TEST_DIPA_QUALIFICATION"; PreparedStatement prep=con.prepareStatement(sql); ResultSet rs=prep.executeQuery(); %> <td width="60%"> <select name="qual"> <option value="" selected>---select---</option> <% while(rs.next()) { String strQualification=rs.getString(1); System.out.println(strQualification); %> <option value=""><%=strQualification%></option> <% } %> </select> </td> </tr> <tr> <td width="38%"> </td> <td width="2%"> </td> <td width="60%"> </td> </tr> </table> </form> </body> </html> |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error while recording Combo Box | bapuji6 | QTP | 1 | 10-26-2007 07:36 AM |
| Sorting and Editing Dropdown Combo | sweetychinnu | ASP.NET | 1 | 10-19-2007 05:23 AM |
| BDC program of KP06 gives error | Geek_Guest | SAP R/3 | 0 | 06-04-2007 11:40 PM |
| combo in jsp | vmshenoy | JSP | 4 | 03-19-2007 12:07 PM |
| Select a different value from the combo box | JobHelper | WinRunner | 1 | 12-26-2006 11:17 AM |