-1

我想编辑学生详细信息。我可以通过将 rollno 作为输入来检索所有字段,但数据库中的 textarea 字段除外。如何从数据库中将数据检索到 textarea。这里的地址字段是 textarea。我无法从数据库中检索地址

editstudent.jsp
<body>  

        <!--<form id="frmExamRegistration" method="post" enctype="multipart/form-data" class="anu">-->


    <form name="f1" method="post" class="anu" action="Edit_studentdetails.jsp">  
    <%@include file="adminheader.jsp"%>
<%@include file="sidemenus.jsp" %>

    <div id="container">
              <div  style="float:right;width:10%;border:0;font-color:#163362"><a href=logout.jsp">Log Out</a></div><br>
        <div class="content"><center>Edit Student</center><br>
            <div class="formElements,rightcol" align="center">
                <label>Rollno:
                 <span><input type="text" id="txtRollno" name="txtRollno" ></span></label>
                       </div><br>



            <div class="buttons">
                <button type="submit" class="primaryAction">Edit</button>
                                <button type="reset" class="primaryAction">Clear</button>

            </div>
                 </div>
         </div>
       </form>
  </body>


edit_studentdetails.jsp

<body>  
    <form name="f1" method="post" class="anu" action="Update_studentdetails.jsp">  
    <%@include file="adminheader.jsp"%>
    <%@include file="sidemenus.jsp" %>
    <%@include file="jsp/jdbcresults.jsp" %>
    <%  

                Connection dbConnection = con;

    String Rollno=request.getParameter("txtRollno");
        String BatchCode="";
        String CourseCode="";
        String Fullname="";
        String Fathername="";
        Date DOB=null;
        String fmtdob=null;
        String Gender="";
        Date DOJ=null;
        String fmtdoj=null;
        String Email="";
        String Phone="";
        String address=null;
        String Hallticketno="";
        java.text.SimpleDateFormat formatter=new java.text.SimpleDateFormat("dd-mm-yyyy");
     //   String Photo=request.getParameter("txtPhoto");


try 
                {

String selectStoredProc = "SELECT * FROM STUDENTS WHERE ROLLNO = '"+Rollno+"'";

                        PreparedStatement ps = dbConnection.prepareStatement(selectStoredProc);
                    ResultSet rs=ps.executeQuery();
                    while(rs.next()) {
                      Rollno = rs.getString("rollno");

                  BatchCode=rs.getString("batchcode");
                          CourseCode=rs.getString("ccode");
                          Fullname=rs.getString("fullname");
                          Fathername=rs.getString("fathername");
                                          DOB=rs.getDate("dob");
                                          // fmtdob =formatter.format(DOB);
                          Gender=rs.getString("gender");
                          DOJ=rs.getDate("doj");
                                         // fmtdoj =formatter.format(DOJ);
                              Email=rs.getString("email");
                          Phone=rs.getString("phone");
                          address=rs.getString("address");
                          Hallticketno=rs.getString("hallticketno");
                    }
                    rs.close();
                    rs = null;


                } 
                catch (Exception e) {
                    System.out.println(e.getLocalizedMessage());
                }
                finally {


                    if(dbConnection != null){
                        dbConnection.close();
                        dbConnection = null;
                    }
                }

    %>
    <div id="container">
              <div  style="float:right;width:10%;border:0;font-color:#163362"><a href=logout.jsp">Log Out</a></div><br>
        <div class="content"><center>Edit Student Details</center><br>
            <div class="formElements,rightcol" align="center" width="100%">



                                 <label>Roll no:
                 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<span><input type="text" id="txtRollno" name="txtRollno" value="<%= Rollno%>" readonly='true'></span></label><br>

                <label>Batch code:
                 &nbsp&nbsp&nbsp;<span><input type="text" id="txtBatchcode" name="txtBatchcode" value="<%= BatchCode%>" readonly='true'></span></label><br>


                <label>Course code:
                 <span><input type="text" id="txtCoursecode" name="txtCoursecode" value="<%= CourseCode %>" readonly='true'></span></label><br>

                <label>Full Name:
                &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<span><input type="text" id="txtFullname" name="txtFullname" value="<%= Fullname %>" ></span></label><br>

                <label>Father Name:&nbsp
                 <span><input type="text" id="txtFathername" name="txtFathername" value="<%= Fathername %>" ></span></label><br>

                <label>Date Of Birth:&nbsp&nbsp&nbsp&nbsp
                                <input type="date" name="txtDob" id="txtDob" value="<%= DOB %>" ></label><br>



                <label>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;Gender:
                    <% if (Gender.equals("male")){%>
                                   <input type=Radio name='txtGender' value='male' checked='true'> Male
                                     <%}else{%>
                                   <input type=Radio name='txtGender' value='male'>Male
                     <%} if (Gender.equals("female")){%>
                   <input type=Radio name='txtGender' value='female' checked='true'> Female</td></tr>
                     <%}else{%>
                   <input type=Radio name='txtGender' value='female'><b> Female</td></tr>
                     <%}%></label><br>

                               <label>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;Date Of Join:
                 <input type="date" name="txtDoj" id="txtDoj" value="<%= DOJ %>" ></label><br>

                                <label>Email id:
                 &nbsp&nbsp&nbsp;<span><input type="text" id="txtEmailid" name="txtEmailid" value="<%= Email %>"  ></span></label><br>

                                <label>Phone No.:
                 &nbsp&nbsp&nbsp;<span><input type="text" id="txtPhoneno" name="txtPhoneno" value="<%= Phone %>" ></span></label><br>

                               <label>Address:
                 &nbsp&nbsp&nbsp;<span><textarea rows="4" cols="30" name="txtaddress" id="txtaddress" textareaObject.value="text" value="<%= address %>" ></textarea></span></label><br> 

                               <label>Hall ticket no.:
                 &nbsp&nbsp&nbsp;<span><input type="text" id="txtHallticketno" name="txtHallticketno"  value="<%= Hallticketno%>" ></span></label><br>

                             <!--<label>Photo:
                                <input type="file" id="txtPhoto" name="txtPhoto" ></span></label><br>-->
                        </div>


            <div class="buttons">
                <button type="submit" class="primaryAction">Edit</button>
                <button type="reset" class="primaryAction">Clear</button>
            </div>
          </div>
         </div>
       </form>
  </body>


update_studentdetails.jsp


<body >  

        <!--<form id="frmExamRegistration" method="post" enctype="multipart/form-data" class="anu">-->


    <form name="f1" method="post" class="anu">  
<table  valign="top" height="800" width="1024"> 
<tr><td colspan="2"><%@include file="adminheader.jsp"%></td></tr>


    <!--<div id="container">
<div class="content"><center><h4> Grades</h4></center> -->

<tr><td colspan="2" bgcolor="#A1A1AE">
              <div  style="float:right;width:10%;border:0;font-color="ffffff";"><a href=logout.jsp">Log Out</a></div></td>
<tr><td height="600" valign="top">      
<%@include file="sidemenus.jsp" %></td>

<td>

<%@include file="jsp/jdbcresults.jsp" %>
<%
     // Hope you are getting the connection part  
                CallableStatement cstmt=null;
        String Rollno=request.getParameter("txtRollno");
        String BatchCode=request.getParameter("txtBatchcode");
        String CourseCode=request.getParameter("txtCoursecode");
        String Fullname=request.getParameter("txtFullname");
        String Fathername=request.getParameter("txtFathername");
        String DOB=request.getParameter("txtDob");
        String Gender=request.getParameter("txtGender");
        String DOJ=request.getParameter("txtDoj");
        String Email=request.getParameter("txtEmailid");
        String Phone=request.getParameter("txtPhoneno");
        String Address=request.getParameter("txtaddress");
        String Hallticketno=request.getParameter("txtHallticketno");

 try {
cstmt=con.prepareCall("{call udp_modifystudent(?,?,?,?,?,?,?,?,?,?,?,?)}");
                cstmt.setString(1,Rollno);
                cstmt.setString(2,BatchCode); 
                cstmt.setString(3,CourseCode);                
                cstmt.setString(4,Fullname);  
                cstmt.setString(5,Fathername);  
                cstmt.setString(6,DOB);  
                cstmt.setString(7,Gender);  
                cstmt.setString(8,DOJ);  
                cstmt.setString(9,Email);  
                cstmt.setString(10,Phone);  
                cstmt.setString(11,Address);  
                cstmt.setString(12,Hallticketno);  
                cstmt.executeUpdate(); 

               out.print("Student updated successfully");
       }
       catch(Exception e){
        out.print("Exception: "+e.getMessage());
                }
       finally {
       cstmt.close();
       con.close();
       }

%>
</td></tr>
</table></form></body>
4

3 回答 3

0
<textarea rows="4" cols="30" name="txtaddress" id="txtaddress" textareaObject.value="text" ><%= address %></textarea>
于 2013-04-24T10:07:52.023 回答
0

与文本框相反,这不是您将内容放入文本区域的方式。您不应该将文本放在“值”属性中,而只是将其放在打开和关闭 textarea 标记之间......

于 2013-04-24T10:06:38.350 回答
0

像这样使用它会起作用

<textarea name="content"><%= rs.getString("addres")%></textarea>
于 2014-04-07T12:29:16.497 回答