Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 25th, 2004, 01:44 AM
Authorized User
 
Join Date: Oct 2004
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:06 PM.


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