Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 25th, 2004, 01:44 AM
Authorized User
 
Join Date: Oct 2004
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Default updation problem

I have a jsp page named security.jsp. my problem is that the below code is not working.

This page shown all the values of database, and there is a update button, after clicking that we can modify rows of the table.


<html>
<body>
<table>
<tr>
<td>

<%@ page import="javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
<%@ page language="java" import="java.sql.*" %>


<%
  try {

DateFormat format = new SImpleDateFormat("dd/MM/yyyy");
format.setLenient(false);

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn=DriverManager.getConnection("jdbc:odbc:pf","s cott","ttlscott");
System.out.println("got connection");

%>

<%
String action = request.getParameter("action");
// Check if an update is requested
if (action != null && action.equals("update")) {
conn.setAutoCommit(false);



PreparedStatement pstatement = conn.prepareStatement(
"UPDATE sec_mast SET sec_no=? , catg_code=?, face_val=?, pur_val=?, int_paid=?, int_recd=?, brkr=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, lf_no=?, mat_date=? where tot_val=? ");

pstatement.setInt(1,Integer.parseInt(request.getPa rameter("sec_no")));
pstatement.setInt(2,Integer.parseInt(request.getPa rameter("catg_code")));
pstatement.setInt(3,Integer.parseInt(request.getPa rameter("face_val")));
pstatement.setInt(4,Integer.parseInt(request.getPa rameter("pur_val")));
pstatement.setInt(5,Integer.parseInt(request.getPa rameter("int_paid")));
pstatement.setInt(6,Integer.parseInt(request.getPa rameter("int_recd")));
pstatement.setInt(7,Integer.parseInt(request.getPa rameter("brkr")));
pstatement.setString(8,request.getParameter("vou_n o"));

java.util.Date vouDate = format.parse(request.getParameter("vou_date"));
pstatement.setDate(9, new java.sql.Date(vouDate.getTime()));

pstatement.setInt(10,Integer.parseInt(request.getP arameter("vou_amt")));

java.util.Date DueDate1 = format.parse(request.getParameter("due_date1"));
pstatement.setDate(11, new java.sql.Date(DueDate1.getTime()));

java.util.Date DueDate2 = format.parse(request.getParameter("due_date2"));
pstatement.setDate(12, new java.sql.Date(DueDate2.getTime()));


pstatement.setString(13,request.getParameter("lf_n o"));

java.util.Date Matur_Date = format.parse(request.getParameter("mat_date"));
pstatement.setDate(14, new java.sql.Date(Matur_Date.getTime()));


pstatement.setInt(15,Integer.parseInt(request.getP arameter("tot_val")));


int rowCount = pstatement.executeUpdate();
conn.setAutoCommit(false);
conn.setAutoCommit(true);
}


%>


<%
// Create the statement
Statement statement = conn.createStatement();


ResultSet rs = statement.executeQuery
  ("SELECT * from sec_mast ");

%>

 <%
  // Iterate over the ResultSet
  while ( rs.next() ) {
%>


   <tr>
  <form action="security_update.jsp" method="get">
    <input type="hidden" value="update" name="action">
    <td><input value="<%= rs.getInt("sec_no") %>" name="sec_no"></td>
    <td><input value="<%= rs.getInt("catg_code") %>" name="catg_code"></td>
    <td><input value="<%= rs.getInt("face_val") %>" name="face_val"></td>
    <td><input value="<%= rs.getInt("pur_val") %>" name="pur_val"></td>
    <td><input value="<%= rs.getInt("int_paid") %>" name="int_paid"></td>
    <td><input value="<%= rs.getInt("int_recd") %>" name="int_recd"></td>
    <td><input value="<%= rs.getInt("brkr") %>" name="brkr"></td>
    <td><input value="<%= rs.getInt("tot_val") %>" name="tot_val"></td>
    <td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
    <td><input value="<%= rs.getDate("vou_date") %>" name="vou_date"></td>
    <td><input value="<%= rs.getInt("vou_amt") %>" name="vou_amt"></td>
    <td><input value="<%= rs.getDate("due_date1") %>" name="due_date1"></td>
    <td><input value="<%= rs.getDate("due_date2") %>" name="due_date2"></td>
    <td><input value="<%= rs.getString("lf_no") %>" name="lf_no"></td>
    <td><input value="<%= rs.getDate("mat_date") %>" name="mat_date"></td>
    <td><input type="submit" value="Update"></td>
    </form>
  </tr>



<%
  }
%>
</table>



<%
// Close the ResultSet
rs.close();

// Close the Statement
statement.close();

// Close the Connection
conn.close();

}catch(ParseException e) {
out.println("do date format error action.<br>");
} catch (SQLException sqle) {
  out.println(sqle.getMessage());
} catch (Exception e) {
  out.println(e.getMessage());
}
%>
</td>
</tr>
</body>
</html>

error shown is as :


HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 18 in the jsp file: /security_master/security_update.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\abhi\org\apache\jsp\se curity_005fmaster\security_005fupdate_jsp.java:65: cannot find symbol
symbol : class DateFormat
location: class org.apache.jsp.security_005fmaster.security_005fup date_jsp
DateFormat format = new SImpleDateFormat("dd/MM/yyyy");
^


An error occurred at line: 18 in the jsp file: /security_master/security_update.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\abhi\org\apache\jsp\se curity_005fmaster\security_005fupdate_jsp.java:65: cannot find symbol
symbol : class SImpleDateFormat
location: class org.apache.jsp.security_005fmaster.security_005fup date_jsp
DateFormat format = new SImpleDateFormat("dd/MM/yyyy");
                        ^


An error occurred at line: 127 in the jsp file: /security_master/security_update.jsp
Generated servlet error:
D:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\abhi\org\apache\jsp\se curity_005fmaster\security_005fupdate_jsp.java:217 : cannot find symbol
symbol : class ParseException
location: class org.apache.jsp.security_005fmaster.security_005fup date_jsp
}catch(ParseException e) {
       ^
3 errors



    org.apache.jasper.compiler.DefaultErrorHandler.jav acError(DefaultErrorHandler.java:84)
    org.apache.jasper.compiler.ErrorDispatcher.javacEr ror(ErrorDispatcher.java:332)
    org.apache.jasper.compiler.Compiler.generateClass( Compiler.java:412)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:472)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:451)
    org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
    org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:511)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:295)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
    javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.28






Similar Threads
Thread Thread Starter Forum Replies Last Post
help in updation sanjeev jha Classic ASP Basics 0 November 12th, 2007 04:17 AM
Problem in Updation. rupen Classic ASP Basics 5 June 27th, 2005 07:17 PM
updation prob.......... abhit_kumar MySQL 0 December 14th, 2004 08:06 AM
Problem in updation abhit_kumar JSP Basics 3 November 30th, 2004 09:47 AM
updation problem abhit_kumar Java Databases 0 November 25th, 2004 01:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.