hi... i have 1 jsp form. my form includes 6 text boxes and 8 dropdowns. I want to insert the data of these textboxe and dropdown to Database. I am using mysql server 5.1.The problem is that when I insert, a blank screen appears. (Data in dropdown is retrieved from the database).. please guide me accordingly or post a simple example using this type of situation. itz urgent.. :) thanku

Do you wanna confirm from database side that is it your insert query is actully executing successfully or not?
What do you mean by blank page?
May be your code contains smthing which forward the response to that blank page.
can you post your code so that it will more clear?

@Neha - Have you checked in your DB if the data is inserted or not.If it is not inserted then was there any exception/error.
Provide us your code snippets and logs.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %>
<%ResultSet resultset =null;%>
<html>
<head>
<title> loggingscreen </title>
</head>
<script>
function checkInput(){

    var x=document.forms["loggingForm"]["Tno"].value;
    if (x==null || x=="")
      {
      alert("Please enter Ticket No.");
      return false;
      }
    var y=document.forms["loggingForm"]["otime"].value;
    if (y==null || y=="")
      {
      alert("Please enter Open Time.");
      return false;
      }
      var z=document.forms["loggingForm"]["brief_desc"].value;
    if (z==null || z=="")
      {
      alert("Please enter the description of ticket.");
      return false;
      }
}
</script>
<body bgcolor="lavender">


<!-- ERROR SECTION STARTS: display errors here --> 
<table border="0" >
    <tr >
           <td> 
           <font size="3" color="red">
           <%
           if(request.getAttribute("loginError")!=null){
               out.println(request.getAttribute("loginError"));
           } 
           %>
           </font>
           </td> 
    </tr>
</table>
<!--  Error section ENDS here -->
<form action="insert.jsp" method="post" name="loggingForm" onsubmit= "return checkInput()" >
<table border="0" bordercolor="gray" cellspacing="0" cellpadding="0" width="772" height="432" align="center">
      <tr>
        <td width="772" height="432" valign="middle" align="center">
          <!-- begining of inner table -->
          <table border="0" cellspacing="0" cellpadding="0" width="750" height="430" align="center">
            <tr>
              <td width="770" height="60" valign="top" align="center">
                <!-- 
  Name        :header.jsp 
  Description :File to be included for header
-->
<table border="0" cellspacing="0" cellpadding="0" width="770" height="60" align="center">
         <tr>
           <td height="90" width="770" align="center"> 
                <img src="ACES_LOGO.JPG" width="980" height="120">
           </td> 
            </tr>
</table>

              </td>
            </tr>
            <!-- end of header -->

            <tr>
              <td class="separator"></td>
            </tr>
            <tr>
              <td width="770" height="20" valign="top"></td>
            </tr>
            <tr>
              <td class="separator"></td>
            </tr>
            <tr>
              <td width="770" height="20" valign="middle">
                <table cellspacing="0" cellpadding="0" border="0" width="770">
                  <tr>
                    <td width="500" height="20" class="dataBlock">Log Tickets Here</td>
                    <td width="200" height="20" class="dataBlock"> Logged In</td>
                    <td width="70" height="20" class="dataBlock">
                      <a href="login.jsp"> SIGNOUT </a>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
            <!-- end of data block -->
            <tr>
              <td class="separator"></td>
            </tr>
            <tr>
              <td width="770" height="370" valign="top">
                <!-- start of workarea -->
                <table border="1" cellspacing="0" cellpadding="0" width="760" height="25" align="center">
                <table border="0" cellspacing="0" cellpadding="0" width="750" height="23" align="center">
                  <tr>
                    <td colspan="6" height="10"></td>
                  </tr>
                  <tr>
                    <td height="23" colspan="4" align="center" class="lastFormLabel"></td>
                  </tr>
                </table>
                <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Ticket No.&nbsp&nbsp;:&nbsp;</td>  
                        <td><input type="text" value="" SIZE="24" name="Tno"></td>
                        <td height="23" width="154" class="leftTopFormLabel" align="right">WIP&nbsp;Time&nbsp;:&nbsp;</td>              
                        <td><input type="text" value="" SIZE="24" name="Wtime"></td>
                     </tr>
                  </table>
                  <br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Own By&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="ownby">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_user_masters") ;
                    %>
                        <%  while(resultset.next()){ %>
            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
        <% } %>
                        </select>
                        </td>
                        <%
        }
        catch(Exception e)
        {
             out.println("wrong entry"+e);
        }
%>
                        <td height="23" width="154" class="leftTopFormLabel" align="right">Resolution Time&nbsp;&nbsp;:&nbsp;</td>              
                        <td width="192" height="23" class="leftTopFormLabel" align="left"><input type="text" value="" SIZE="24" name="Rtime"></td>
                     </tr>
                  </table><br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Priority&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="priority">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_priority_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                        </select>
                        </td>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>

                        <td height="23" width="154" class="leftTopFormLabel" align="right">Module&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="module">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_module_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>
                        </select>
                        </td>
                     </tr>
                  </table><br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Assignee Name&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="assignee_name">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_assignee_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                        </select>
                        </td>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>
                        <td height="23" width="154" class="leftTopFormLabel" align="right">Sub-Module&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="sub_module">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_sub_module_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                        </select>
                        </td>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>
                     </tr>
                  </table><br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Primary Assignment&nbsp&nbsp;:&nbsp;</td>  
                        <td WIDTH="186"><input type="text" value="ACES L2-L3 TEAM" SIZE="24" name="primary_assn"></td>
                        <td height="23" width="159" class="leftTopFormLabel" align="right">Category&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="category">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_category_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                        </select>
                        </td>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>
                     </tr>
                  </table></br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Problem Status&nbsp&nbsp;:&nbsp;</td>  
                        <td>
                        <select style="width:170px;" name="prob_status">
                        <option>Open</option>
                        <option>ReOpen</Option>
                        </select>
                        </td>
                        <td height="23" width="150" class="leftTopFormLabel" align="right">Sub Category&nbsp&nbsp;:&nbsp;</td>  
                        <td width="192">
                        <select style="width:170px;" name="sub_category">
                        <%
                        try{
                    //Class.forName("com.mysql.jdbc.Driver").newInstance();
                    Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/aces_incident_management", "root", "wipro@123");
                            Statement statement = connection.createStatement() ;
                            resultset =statement.executeQuery("select * from aces_sub_category_masters") ;
                    %>
                            <%  while(resultset.next()){ %>
                            <option value=<%= resultset.getString(1)%>><%= resultset.getString(2)%></option>
                            <% } %>
                        </select>
                        </td>
                    <%
                            }
                            catch(Exception e)
                            {
                                 out.println("wrong entry"+e);
                            }
                    %>
                        </tr>
                  </table></br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="left">
                     <tr>
                        <td height="23" width="214" class="leftTopFormLabel" align="right">Open Time&nbsp;&nbsp;:&nbsp;</td>              
                        <td><input type="text" value="" SIZE="24" name="otime"></td>
                        <td height="23" width="154" class="leftTopFormLabel" align="right">Brief&nbsp;Description&nbsp;:&nbsp;</td>              
                        <td><input type="text" value="" SIZE="24" name="brief_desc"></td>
                     </tr>
                  </table><br><br><br>
                  <table border="0" cellspacing="0" width="750" cellpadding="0" align="center">
                     <tr>
                          <td align="center"><input type="submit" value="&nbsp&nbsp SUBMIT &nbsp&nbsp" onclick="myFunction()" SIZE="24" name="SUBMIT"></td> 
                     </tr>
                  </table>
            </td>
          </tr>  
     <!-- end of workarea-->
</table>  
        </table>
<!-- end of inner table -->
</td>                    
</tr>                    
</table>
<%
String Tno=request.getParameter("Tno");
String Wtime=request.getParameter("Wtime");
String ownby=request.getParameter("ownby");
String Rtime=request.getParameter("Rtime");
String priority=request.getParameter("priority");
String module=request.getParameter("module");
String assignee_name=request.getParameter("assignee_name");
String sub_module=request.getParameter("sub_module");
String primary_assn=request.getParameter("primary_assn");
String category=request.getParameter("category");
String prob_status=request.getParameter("prob_status");
String sub_category=request.getParameter("sub_category");
String otime=request.getParameter("otime");
String brief_desc=request.getParameter("brief_desc");
String connectionURL = "jdbc:mysql://localhost:3306/aces_incident_management";
Connection connection = null;
PreparedStatement pstatement = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
int updateQuery = 0;

try{
connection = DriverManager.getConnection
              (connectionURL, "root", "wipro@123");
String queryString = " insert into aces_incident_details (Tno, Wtime, ownby, Rtime, priority, module, assignee_name, sub_module, primary_assn, category, prob_status, sub_category, otime, brief_desc) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
pstatement = connection.prepareStatement(queryString);
pstatement.setString (1, Tno);
      pstatement.setString (2, Wtime);
      pstatement.setString   (3, ownby);
      pstatement.setString(4, Rtime);
      pstatement.setString    (5, priority);
      pstatement.setString (6, module);
      pstatement.setString (7, assignee_name);
      pstatement.setString   (8, sub_module);
      pstatement.setString(9, primary_assn);
      pstatement.setString    (10, category);
      pstatement.setString (11, prob_status);
      pstatement.setString (12, sub_category);
      pstatement.setString(13, otime);
      pstatement.setString    (14,brief_desc);
      updateQuery = pstatement.executeUpdate();
                            if (updateQuery != 0) { %>
                   <br>
                   <TABLE style="background-color: #E3E4FA;" 
                   WIDTH="30%" border="1">
                      <tr><th>Data is inserted successfully 
                    in database.</th></tr>
                   </table>
              <%
              }
            } 
            catch (Exception ex) {
            out.println("Unable to connect to batabase.");

               }
            finally {
                // close all the connections.
                pstatement.close();
                connection.close();
            }
   %>      
</form>
</body>
</html>

you don't have an any codes??

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.