what is wrong with my JSP codes for updating a form?

what is wrong with my JSP codes for updating a form?

Hi experts,

I have tried to emulate a code from a textbook but it doesn't work in my program. Hope someone can advise me where I had gone wrong.

Tks.

I've set up my database as follows:-

ID - autoincrement and it's INT. NRIC No - String. Name - String.

Here's snippet of my codes:-

<%    Connection conn = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            Statement stmt = null;

            try {
                Class.forName("com.mysql.jdbc.Driver");
                conn = DriverManager.getConnection("jdbc:mysql://localhost/ADFJA) 
                stmt = conn.createStatement();
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
            if (request.getParameter("action") != null) {
                int selectionId = Integer.parseInt(request.getParameter("ID"));
                String NRIC = request.getParameter("txtNRIC");
                String Name = request.getParameter("txtFullName");
String sql = "UPDATE tutors SET strNRICNO='" + NRIC
                        + " ', strTutorName=' " + Name + "'where ID= " + selectionId;
                //out.println(sql);
                stmt.executeUpdate(sql);

%>
<html>
    Member Id = <%= request.getParameter("ID")%> Successfully Updated ! <br><br>

</html>
<%} else {%>
<%
                int selectionId = Integer.parseInt(request.getParameter("ID"));
                String MemberNo = null;

String strNRIC = null;
                String strName = null;
rs = stmt.executeQuery("select * from Members where ID = "   + selectionId + "");
                if (rs.next()) {
                    strNRIC = rs.getString("strNRICNO");
                    strTutorName = rs.getString("strTutorName");
  } else {
                    strNRIC = "Unkown.";
                    strTutorName = "Unkown.";
  </head>
    <body><center>
            <form action="Update.jsp" method ="post" name="update">
        </center>
        <input type="hidden" value="list" name="action">
        <input type="hidden" value=<%= request.getParameter("ID")%> name="ID"">
        <div id="header">Welcome to Admin</div>
                    <h5>Member Update Form </h5>
            <input type = "hidden" value="list" name="action">
            <table>
                <tr><td>Tutor's ID</td>
                    <td><%= selectionId%></td>
                <tr>
                    <td>Full Name</td>
                    <td><input type="text" id="txtFullName" name="txtFullName" value="<%=strName%>"></td>
                </tr>
                <tr>
     <input type="submit" id="btnSubmit" name="Update Member" value="Update Member<%= request.getParameter("ID")%>">
            </td></tr>
    </table>
    <a href ="logout.jsp">Log Out</a>
</div>
</form>
</body>
</html>
<%}%

I hope to hear from you soon. Thanks.

View Answers









Related Tutorials/Questions & Answers:
what is wrong with my JSP codes for updating a form?
What's wrong with my pagination code in JSP?
Advertisements
What is wrong with my servlet?
What's wrong with my form? - Java Beginners
What is wrong with this line
what is wrong with this program
what is wrong in this program
what is wrong in this program......
ModuleNotFoundError: No module named 'formv'
ModuleNotFoundError: No module named 'formy'
ModuleNotFoundError: No module named 'forml'
Needed jsp codes
Request for codes - JSP-Servlet
Not sure whats wrong with my code HELP PLEASE?!?!
jsp and ejb codes - EJB
What are different normalization forms?
Updating Ms Access Database using jsp - JSP-Servlet
inteconnecting forms - JSP-Servlet
Multiple forms in JSP - JSP-Servlet
what are the codes for uploading and downloading files in and from database?
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
JSP WITH MULTIPLE FORMS
Multiple Forms in JSP
JSP - Abobe Interactive Forms - JSP-Servlet
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-pro-forma-sequence'
ModuleNotFoundError: No module named 'odoo10-addon-account-invoice-pro-forma-sequence'
Wrong parameter values while exporting data from jsp to excel
please check my code is wrong or ok.it was not work .this is form validation in javascript using jsf page
What is JSP is in layman's terms?
Clarify my doubt - JSP-Servlet
what is wrong in this program?I have netbeans 7.0 & jdk 7. please do corrections.
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ?
What is the best way to learn Java on my own?
what the use of taglib - JSP-Servlet
ModuleNotFoundError: No module named 'wrong'
wrong year
What is the difference between JSF, Servlet and JSP?
how to point my jsp form action to servlet? - JSP-Servlet
Capturing JSP Content Within My Strut Action Servlet - JSP-Servlet
codes for displaying in calendar
coding for updating profile
Further advice needed on my last question - JSP-Servlet
What should I study on my own to become a data scientist?
I really hate my data scientist job. What's your experience?

Ads