Link to home
Start Free TrialLog in
Avatar of timjg
timjg

asked on

Beans files errors

This is Error Compiling JSP File  - part 2

Kennethxu's solution worked.  Thank you.  Now when I compile it shows errors in my two beans java files.  Immediately below are the generated errors and I will follow with the two java files.  Thanks for any help you can provide..

trackingView$jsp.java [86:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingView$jsp
                TrackingDataBean trackingData = null;
                ^
trackingView$jsp.java [89:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingView$jsp
                    trackingData= (TrackingDataBean)
                                   ^
trackingView$jsp.java [94:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingView$jsp
                            trackingData = (TrackingDataBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TrackingDataBean");
                                            ^
trackingView$jsp.java [142:1] cannot resolve symbol
symbol  : class TrackingBean
location: class org.apache.jsp.trackingView$jsp
                        TrackingBean tracking;
                        ^
trackingView$jsp.java [145:1] cannot resolve symbol
symbol  : class TrackingBean
location: class org.apache.jsp.trackingView$jsp
                            tracking = ( TrackingBean ) trackingListIterator.next();
                                         ^
trackingLogin$jsp.java [79:1] cannot resolve symbol
symbol  : class TrackingBean
location: class org.apache.jsp.trackingLogin$jsp
                TrackingBean tracking = null;
                ^
trackingLogin$jsp.java [82:1] cannot resolve symbol
symbol  : class TrackingBean
location: class org.apache.jsp.trackingLogin$jsp
                    tracking= (TrackingBean)
                               ^
trackingLogin$jsp.java [87:1] cannot resolve symbol
symbol  : class TrackingBean
location: class org.apache.jsp.trackingLogin$jsp
                            tracking = (TrackingBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TrackingBean");
                                        ^
trackingLogin$jsp.java [106:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingLogin$jsp
                TrackingDataBean trackingData = null;
                ^
trackingLogin$jsp.java [109:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingLogin$jsp
                    trackingData= (TrackingDataBean)
                                   ^
trackingLogin$jsp.java [114:1] cannot resolve symbol
symbol  : class TrackingDataBean
location: class org.apache.jsp.trackingLogin$jsp
                            trackingData = (TrackingDataBean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "TrackingDataBean");
                                            ^

11 errors
Errors compiling trackingLogin

The two .java files follow:

// TrackingBean.java
// JavaBean to store branch sales data for a database

public class TrackingBean {

    private String branch, year, month, day;
    // private int
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }
   
}


// TrackingDataBean.java
// Class TrackingDataBean makes a database connection and supports
// inserting and retrieving data from the database/


// Java core packages
import java.sql.*;
import java.io.*;
import java.util.*;


public class TrackingDataBean {
  private Connection connection;
  private PreparedStatement addRecord, getRecords;
  private Statement stat;
   
  // construct TitlesBean object
  public TrackingDataBean() throws Exception
  {
      //System.setProperty( "
     
      // load the Ability driver
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
     
      // connect to the database
      connection = DriverManager.getConnection(
          "jdbc:odbc:Tracking" );
         
      //Statement stat=con.createStatement();
      //Statement stat=connection.createStatement();
      stat = connection.createStatement();
  }
 
  // return an ArrayList of TrackingBeans
  public ArrayList getTrackingList() throws SQLException
  {
      ArrayList trackingList = new ArrayList();
     
      // obtain list of titles
     
       
      ResultSet results = stat.executeQuery(
          "SELECT branch, year, month, day FROM Tracking" );
         
         
     
      // get row data
      while ( results.next() ) {
          TrackingBean tracking = new TrackingBean();
         
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
         
          trackingList.add( tracking );
      }
     
      return trackingList;
     
  }
 
  // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" );
  }    
   
  // close statemetns and terminate database connection
  protected void finalize()
  {
      // attempt to close database connection
      try {
          stat.close();
          connection.close();
      }
     
      // process SQLException on close operation
      catch ( SQLException sqlException ) {
          sqlException.printStackTrace();
      }
  }  

}

Avatar of copyPasteGhost
copyPasteGhost
Flag of Canada image

I think the files are not located in the right spot

-jspfiles
-WEB-INF
          -classes
              -TrackingBean.class

you need this directory sturcture for your beans to work
Ghost
Avatar of timjg
timjg

ASKER

Both of the .class files are located in the WEB-INF/classes directory.  Is there something else going on?
ummm I just noticed this...
are you importing that file?
<%@ page import="TrackingDataBean "%>
cause if you are going to use the class like that...you need to import it.
Ghost
you might have to also put the beans within a package.

like package mypackage;
public class TrackingDataBean {
.....

}

and then you would store the complied class files here.
WEB-INF/classes/mypackage

that might work.
Ghost
Avatar of timjg

ASKER

I have three JSP files:

1) login page which creates the form for the user to input values into database which has the following -

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>

<%-- beans used in this JSP --%>
<jsp:useBean id = "tracking" scope = "page"
   class = "TrackingBean" />
<jsp:useBean id = "trackingData" scope = "request"
   class = "TrackingDataBean" />

2) view page which generates the data from the database for the user which has the following:

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>
<%@ page import = "java.util.*" %>
<%-- <%@ page import = ".jsp.beans.*" %> --%>

<%-- TrackingDataBean to obtrain tracking list --%>
<jsp:useBean id = "trackingData" scope = "request"
    class = "TrackingDataBean" />

3) error page which displays any error in the app to the user which has the following:

<%-- page settings --%>
<%@ page isErrorPage = "true" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.sql.*" %>

If you need to see the entire JSP files, please let me know.  Thanks a lot.
try putting the beans in a package and do what I suggested above that should work.
Ghost
you will have to change this too.
FROM:

>><jsp:useBean id = "tracking" scope = "page"
>>   class = "TrackingBean" />
>><jsp:useBean id = "trackingData" scope = "request"
>>   class = "TrackingDataBean" />

TO:
<jsp:useBean id = "tracking" scope = "page"
   class = "mypackage.TrackingBean" />
<jsp:useBean id = "tracking" scope = "request"
   class = "mypackage.TrackingDataBean" />

Ghost
Avatar of timjg

ASKER

I'll give that a shot..stay tuned.  Thanks.
Avatar of timjg

ASKER

When I create a package, I get compilation errors on the TrackingDataBean file so I've reverted back to where we started.  Would you be willing to reveiw my two java files and three jsp files if I pasted them here?  I'd be happy to assign more points as well.
sure that sounds great.
Post away
ghost
Avatar of Mick Barry
> I get compilation errors on the TrackingDataBean file so I've reverted back to where we started.

your TrackingDataBean must be in a package.
What ere the errors?
If you follow the suggestions that I posted. It should work without a problem.

1)   you need a package.
      add this statement to all your .java files.
      package trackPac;

2)   your bean statements must be changed to this..
      <jsp:useBean id = "tracking" scope = "page"
          class = "trackPac.TrackingBean" />
      <jsp:useBean id = "tracking" scope = "request"
          class = "trackPac.TrackingDataBean" />

3)   You must be using this directory structure

-jspfiles
-WEB-INF
          -classes
              -trackPac
                   -TrackingBean.class
                   -TrackingDataBean.class

This will work.
hope that helps,
Ghost
Avatar of timjg

ASKER

I followed your comment #1 above and that's where I get compilation errors.  So, I'd still like you to reveiw my files if you don't mind.  I think I'll just muddy up the files without someone else's eyes on them.  Please modify them as you see necessary.  I'm using the NetBeans IDE and the LiteWebServer from Gefion Software.  Thanks a lot.  I look forward to your reply.

The directory structure I set up is as follows:

c:\program files\lws-3.0.3\webapps\tracking\
                                                        images\
                                                        jsp\
                                                        WEB-INF\
                                                            classes\

Here are the files (java first, then jsp):

// TrackingBean.java
// JavaBean to store branch sales data for a database

//package dailyTracking;

public class TrackingBean {

    private String branch, year, month, day;
    // private int
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }
   
}


// TrackingDataBean.java
// Class TrackingDataBean makes a database connection and supports
// inserting and retrieving data from the database/

//package dailyTracking;

// Java core packages
import java.sql.*;
import java.io.*;
import java.util.*;


public class TrackingDataBean {
  private Connection connection;
  private PreparedStatement addRecord, getRecords;
  private Statement stat;
   
  // construct TitlesBean object
  public TrackingDataBean() throws Exception
  {
      //System.setProperty( "
     
      // load the Ability driver
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
     
      // connect to the database
      connection = DriverManager.getConnection(
          "jdbc:odbc:Tracking" );
         
      //Statement stat=con.createStatement();
      //Statement stat=connection.createStatement();
      stat = connection.createStatement();
  }
 
  // return an ArrayList of TrackingBeans
  public ArrayList getTrackingList() throws SQLException
  {
      ArrayList trackingList = new ArrayList();
     
      // obtain list of titles
     
       
      ResultSet results = stat.executeQuery(
          "SELECT branch, year, month, day FROM Tracking" );
         
         
     
      // get row data
      while ( results.next() ) {
          TrackingBean tracking = new TrackingBean();
         
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
         
          trackingList.add( tracking );
      }
     
      return trackingList;
     
  }
 
  // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" );
  }    
   
  // close statemetns and terminate database connection
  protected void finalize()
  {
      // attempt to close database connection
      try {
          stat.close();
          connection.close();
      }
     
      // process SQLException on close operation
      catch ( SQLException sqlException ) {
          sqlException.printStackTrace();
      }
  }  
}


?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- trackingLogin.jsp -->

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>

<%-- beans used in this JSP --%>
<jsp:useBean id = "tracking" scope = "page"
   class = "TrackingBean" />
<jsp:useBean id = "trackingData" scope = "request"
   class = "TrackingDataBean" />

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
    <title>Daily Sales Tracking</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript" type="text/JavaScript">
    <!--
    function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
    }

    function MM_validateForm() { //v4.0
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
    }
    //-->
    </script>

    <style type="text/css">
    <!--

    body {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
    }
    -->
    </style>
</head>

<body>
   <jsp.setProperty name = "tracking" property = "*" />

   <% // start scriplet

        if ( tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ) {

   %> <%-- end scriptlet to insert fixed template data --%>

            <table width="700" height="66" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="43"><div align="center"><img src="logo.jpg" alt="U.S. Bank - Five Star Service Guaranteed" width="175" height="48"></div></td>
  </tr></table>
<form action="trackingLogin.jsp" method="post" name="form1" onSubmit="MM_validateForm('name','','R','email','','RisEmail','comments','','R');return document.MM_returnValue">
  <table width="900" height="1136" border="0" align="center" cellpadding="2" cellspacing="2">
    <tr>
      <td height="50" colspan="6"> <div align="center"></h1> <strong>Please report
          sales activity for the previous business day</h1></strong> </div></td>
    </tr>
    <tr>
      <td colspan="2"> <div align="right"></div></td>
      <td width="15%"><div align="right">Branch: </div></td>
      <td width="24%"><select name="branch" size="1" id="branch">
          <option value="104th &amp; Federal">104th &amp; Federal</option>
          <option value="14th &amp; Taft">14th &amp; Taft</option>
          <option value="28th &amp; Quebec">28th &amp; Quebec</option>
        <option value="48th &amp; Tower">48th &amp; Tower</option>
          <option value="64th &amp; McIntyre">64th &amp; McIntyre</option>
          <option value="Arapahoe &amp; Parker">Arapahoe &amp; Parker</option>
        <option value="Castle Pines">Castle Pines</option>
          <option value="Castle Rock">Castle Rock</option>
          <option value="Chatfield &amp; Wadsworth">Chatfield &amp; Wadsworth</option>
        <option value="Cheyenne Meadows">Cheyenne Meadows</option>
          <option value="Englewood">Englewood</option>
          <option value="Harmony &amp; College">Harmony &amp; College</option>
        <option value="Louisville">Louisville</option>
          <option value="Miramonte">Miramonte</option>
          <option value="Monument">Monument</option>
        <option value="Nelson &amp; Hover">Nelson &amp; Hover</option>
          <option value="Parker">Parker</option>
        <option value="Powers &amp; Stetson">Powers &amp; Stetson</option>
          <option value="Pueblo">Pueblo</option>
          <option value="Sable &amp; Bromley">Sable &amp; Bromley</option>
        <option value="Smoky Hill">Smoky Hill</option>
          <option value="Thornton">Thornton</option>
        <option value="Wadsworth &amp; Jewel">Wadsworth &amp; Jewel</option>
          <option value="Wildcat Reserve">Wildcat Reserve</option>
          <option value="Windsor">Windsor</option>
        </select>
        *</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Date of Sales Activity:</div>
        <div align="center"> </div></td>
      <td colspan="3"> <div align="left">
          <select name="year" size="1" id="year">
            <option value="Year">Year</option>
            <option value="2004">2004</option>
            <option value="2005">2005</option>
          <option value="2006">2006</option>
            <option value="2007">2007</option>
          </select>
          *
          <select name="month" size="1">
            <option value="Month">Month</option>
            <option value="January">January</option>
            <option value="February">February</option>
            <option value="March">March</option>
          <option value="April">April</option>
            <option value="May">May</option>
            <option value="June">June</option>
            <option value="July">July</option>
          <option value="August">August</option>
            <option value="September">September</option>
            <option value="October">October</option>
            <option value="November">November</option>
          <option value="December">December</option>
          </select>
          *
          <select name="day" id="day">
            <option value="Day">Day</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
          <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
          <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
          <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
          <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
          <option value="31">31</option>
          </select>
          * </div></td>
    </tr>

    <tr>
      <td width="3%"> <input type="hidden" name="response" value="response.txt"></td>
      <td colspan="3"><img src="Capella/Sites%20by%20Design/images/transparent.gif" width="1" height="1">*required</td>
      <td colspan="2"> <input type="hidden" name="subject" value="Service Inquiry"></td>
    </tr>    
    <tr>
      <td colspan="4"><div align="center"><strong>Loan Activity:</strong></div></td>
      <td colspan="2"><div align="center"><strong>DDA Activity:</strong></div></td>
    </tr>
    <tr>
      <td height="25" colspan="3"> <div align="right">Installment Closed ($):</div></td>
      <td><input type="text" name="textfield"></td>
      <td width="22%"><div align="right">Checking Opened:</div></td>
      <td width="24%"><input type="text" name="checking_opened"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Equiline Closed ($):</div></td>
      <td><input type="text" name="equiline_closed"></td>
      <td width="22%"><div align="right">Checking Closed:</div></td>
      <td width="24%"><input type="text" name="checking_closed"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Small Business Closed ($):</div></td>
      <td><input type="text" name="small_business_closed"></td>
      <td width="22%"><div align="right">Savings Opened:</div></td>
      <td width="24%"><input type="text" name="savings_opened"></td>
    </tr>
    <tr>
      <td colspan="4"><div align="center"><strong>Pipeline:</strong></div></td>
      <td width="22%"><div align="right">Savings Closed:</div></td>
      <td width="24%"><input type="text" name="savings_closed"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Installment ($):</div></td>
      <td><input type="text" name="installment_pipeline"></td>
      <td colspan="2"><div align="center"><strong>HIMM Accounts:</strong></div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Equiline ($):</div></td>
      <td><input type="text" name="equiline_closed"></td>
      <td><div align="right">Accounts Opened:</div></td>
      <td><input type="text" name="himm_accounts_opened"></td>
    </tr>
    <tr>
      <td height="39" colspan="3"> <div align="right">Small Business ($):</div></td>
      <td><input type="text" name="small_business_pipeline"></td>
      <td><div align="right">New Money ($):</div></td>
      <td><input type="text" name="himm_new_money"></td>
    </tr>
    <tr>
      <td height="28" colspan="4"> <p align="center"><strong>Promotional/Focus:</strong></p></td>
      <td><div align="right">Total Money ($):</div></td>
      <td><input type="text" name="himm_total_money"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">CDs Sold (#):</div></td>
      <td><input type="text" name="cds_sold"></td>
      <td colspan="2"><div align="center"><strong>Hours:</strong></div></td>
    </tr>
    <tr>
      <td height="33" colspan="3"> <div align="right">CDs Sales ($):</div></td>
      <td><input type="text" name="cds_sales"></td>
      <td><div align="right">Weekly Regular Hours:</div></td>
      <td><input type="text" name="weekly_regular_hours"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Loan Applications (#):</div></td>
      <td><input type="text" name="loan_applications"></td>
      <td><div align="right">Weekly OT Hours:</div></td>
      <td><input type="text" name="weekly_OT_hours"></td>
    </tr>
    <tr>
      <td height="31" colspan="3"> <div align="right">Credit Insurance Sold (#):</div></td>
      <td><input type="text" name="credit_insurance_sold"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Internet Banking (#):</div></td>
      <td><input type="text" name="internet_banking"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Visa Check Cards (#):</div></td>
      <td><input type="text" name="visa_check_cards"></td>
      <td colspan="2"><div align="center"><strong>When you're finished, please click Submit</strong></div></td>
    </tr>
    <tr>
      <td height="28" colspan="4"> <div align="center"><strong>Financial Specialist:</strong></div></td>
      <td colspan="2"><div align="center"><strong>Click Reset to re-enter</strong></div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FS Appointments (#):</div></td>
      <td><input type="text" name="fs_appointments"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FS Sales ($):</div></td>
      <td><input type="text" name="fs_sales"></td>
      <td> <div align="right"><input name="submit" type="submit" id="submit" onClick="MM_validateForm('name','','R','email','','RisEmail');return document.MM_returnValue" value="    Submit    " />        </div></td>
                  <td> <div align="left"><input type="reset" name="Reset" value="    Reset    ">        </div></td>      
    </tr>
    <tr>
      <td height="35" colspan="3"> <div align="right">FS Insurance Policies Sold
          (#):</div></td>
      <td><input type="text" name="fs_insurance_policies"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="29" colspan="4"> <p align="center"><strong>Financial Consultant:</strong></p></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FC Appointments (#):</div></td>
      <td><input type="text" name="fc_appointments"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FC Sales ($):</div></td>
      <td><input type="text" name="fc_sales"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4">&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr>
  </table>
</form>

    <% //continue scriptlet

        } // end if
        else {
            trackingData.addTracking( tracking );

   %> <%-- end scriptlet to insert jsp:forward action --%>

        <%-- forward to display tracking contents --%>
        <jsp:forward page = "trackingView.jsp" />

   <% //continue scriptlet

        } // end else
   %> <%-- end scriplet --%>

</body>

</html>


<?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- trackingView.jsp -->

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>
<%@ page import = "java.util.*" %>
<%-- <%@ page import = "dailyTracking.*" %> --%>


<%-- TrackingDataBean to obtrain tracking list --%>
<jsp:useBean id = "trackingData" scope = "request"
    class = "TrackingDataBean" />

<html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
<title>Daily Sales Tracking</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--

body {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
}
-->
</style>
</head>

<body>
<table width="700" height="66" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="43"><div align="center"><img src="logo.jpg" alt="U.S. Bank - Five Star Service Guaranteed" width="175" height="48"></div></td>
  </tr></table>

    <% // start scriptlet

        List trackingList = trackingData.getTrackingList();
        Iterator trackingListIterator = trackingList.iterator();
        TrackingBean tracking;

        while ( trackingListIterator.hasNext() ) {
            tracking = ( TrackingBean ) trackingListIterator.next();

   %> <%-- end scriptlet; insert fixed template data --%>

<table width="450" height="1232" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr>
    <td width="52%"> <div align="right"><strong>Branch: </strong></div></td>
    <td><%= tracking.getBranch() %></td>
  </tr>
  <tr>
    <td><div align="center"><strong>Date of Sales Activity:</strong></div>
      <div align="center"> </div></td>
    <td width="48%"> <div align="left"> </div></td>
  </tr>
  <tr>
    <td><div align="right">Year</div></td>
    <td><%= tracking.getYear() %></td>
  </tr>
  <tr>
    <td><div align="right">Month</div></td>
    <td><%= tracking.getMonth() %></td>
  </tr>
  <tr>
    <td><div align="right">Day</div></td>
    <td><%= tracking.getDay() %></td>
  </tr>
  <tr>
    <td><div align="center"><strong>Loan Activity:</strong></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="25"> <div align="right">Installment Closed ($):</div></td>
    <td><input type="text" name="installment_closed"></td>
  </tr>
  <tr>
    <td><div align="right">Equiline Closed ($):</div></td>
    <td><input type="text" name="equiline_closed"></td>
  </tr>
  <tr>
    <td><div align="right">Small Business Closed ($):</div></td>
    <td><input type="text" name="small_business_closed"></td>
  </tr>
  <tr>
    <td><div align="center"><strong>Pipeline:</strong></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">Installment ($):</div></td>
    <td><input type="text" name="installment_pipeline"></td>
  </tr>
  <tr>
    <td><div align="right">Equiline ($):</div></td>
    <td><input type="text" name="equiline_closed"></td>
  </tr>
  <tr>
    <td height="39"> <div align="right">Small Business ($):</div></td>
    <td><input type="text" name="small_business_pipeline"></td>
  </tr>
  <tr>
    <td height="28"> <p align="center"><strong>Promotional/Focus:</strong></p></td>
    <td height="28">&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">CDs Sold (#):</div></td>
    <td><input type="text" name="cds_sold"></td>
  </tr>
  <tr>
    <td height="33"> <div align="right">CDs Sales ($):</div></td>
    <td><input type="text" name="cds_sales"></td>
  </tr>
  <tr>
    <td><div align="right">Loan Applications (#):</div></td>
    <td><input type="text" name="loan_applications"></td>
  </tr>
  <tr>
    <td height="31"> <div align="right">Credit Insurance Sold (#):</div></td>
    <td><input type="text" name="credit_insurance_sold"></td>
  </tr>
  <tr>
    <td><div align="right">Internet Banking (#):</div></td>
    <td><input type="text" name="internet_banking"></td>
  </tr>
  <tr>
    <td><div align="right">Visa Check Cards (#):</div></td>
    <td><input type="text" name="visa_check_cards"></td>
  </tr>
  <tr>
    <td height="28"> <div align="center"><strong>Financial Specialist:</strong></div></td>
    <td height="28">&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">FS Appointments (#):</div></td>
    <td><input type="text" name="fs_appointments"></td>
  </tr>
  <tr>
    <td><div align="right">FS Sales ($):</div></td>
    <td><input type="text" name="fs_sales"></td>
  </tr>
  <tr>
    <td height="35"> <div align="right">FS Insurance Policies Sold (#):</div></td>
    <td><input type="text" name="fs_insurance_policies"></td>
  </tr>
  <tr>
    <td height="29"> <p align="center"><strong>Financial Consultant:</strong></p></td>
    <td height="29">&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">FC Appointments (#):</div></td>
    <td><input type="text" name="fc_appointments"></td>
  </tr>
  <tr>
    <td><div align="right">FC Sales ($):</div></td>
    <td><input type="text" name="fc_sales"></td>
  </tr>
  <tr>
    <td height="29"> <p align="center"><strong>DDA Activity:</strong></p></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="30"> <p align="right">Checking Opened:</p></td>
    <td width="48%"><input type="text" name="checking_opened"></td>
  </tr>
  <tr>
    <td><div align="right">Checking Closed:</div></td>
    <td width="48%"><input type="text" name="checking_closed"></td>
  </tr>
  <tr>
    <td><div align="right">Savings Opened:</div></td>
    <td width="48%"><input type="text" name="savings_opened"></td>
  </tr>
  <tr>
    <td><div align="right">Savings Closed:</div></td>
    <td width="48%"><input type="text" name="savings_closed"></td>
  </tr>
  <tr>
    <td><div align="center"><strong>HIMM Accounts:</strong></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">Accounts Opened:</div></td>
    <td><input type="text" name="himm_accounts_opened"></td>
  </tr>
  <tr>
    <td><div align="right">New Money ($):</div></td>
    <td><input type="text" name="himm_new_money"></td>
  </tr>
  <tr>
    <td><div align="right">Total Money ($):</div></td>
    <td><input type="text" name="himm_total_money"></td>
  </tr>
  <tr>
    <td><div align="center"><strong>Hours:</strong></div></td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><div align="right">Weekly Regular Hours:</div></td>
    <td><input type="text" name="weekly_regular_hours"></td>
  </tr>
  <tr>
    <td><div align="right">Weekly OT Hours:</div></td>
    <td><input type="text" name="weekly_OT_hours"></td>
  </tr>
</table>

    <% //continue scriptlet

        } // end while

   %> <%-- end scriptlet --%>

</body>
</html>


<?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- trackingErrorPage.jsp -->

<%-- page settings --%>
<%@ page isErrorPage = "true" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.sql.*" %>

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title>Error!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
    .error


{
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
}

</style>
</head>

<body>
    <p class = "error">

    <% // scriptlet to determine exception type
       // and output beginning of error message
       if ( exception instanceof SQLException ) {
    %>

        An SQLException

    <%
        } else if (exception instanceof ClassNotFoundException ) {
    %>    
     
        A ClassNotFoundException

    <%
        } else {
    %>

        An exception

     <%
        }
     %>

    <%-- end scriptlet to insert fixed template data --%>

        <%-- continue error message output --%>
        occurred while entering data in the tracking database.

    </p>

    <p class = "error">
        The error meassage was:<br />
        <%= exception.getMessage() %>
    </p>

    <p class = "error">Please try again later.</p>
    </body>

</html>
   
Apply the changes suggested by copyPasteGhost
Avatar of timjg

ASKER

Thanks copyPasteGhost, your instruction helped.  Now, I'm getting an SQL exception that the database can't be found.  I've placed the database called TRACKING in the trackPac subdirectory and when I call the jsp file that should display the database contents I get the following error:

An SQLException occurred while entering data in the tracking database.

The error meassage was:
[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the input table or query 'Tracking'. Make sure it exists and that its name is spelled correctly.

Please try again later.

Here is the current code requesting connection to the database:

 public TrackingDataBean() throws Exception
  {
      //System.setProperty( "
     
      // load the Ability driver
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
     
      // connect to the database
      connection = DriverManager.getConnection(
          "jdbc:odbc:TRACKING" );
         
      //Statement stat=con.createStatement();
      //Statement stat=connection.createStatement();
      stat = connection.createStatement();
  }

Am I overlooking something?  Thanks again for your help.
placed the database at the same level as your jsp files.
Ghost
was the database code ever working?
Avatar of timjg

ASKER

I placed the database in the jsp subdirectory but I suspect that the databse code is incorrect.  I did notice I had the database as Tracking in the connection and SQL statements which I changed but the error keeps showing that it can't find the database Tracking.  The idea is that the jsp login page presents the form which upon completion and the submit button being depressed accesses the database, enters the contents of the form and then forwards to the jsp view page which shows the contents of the database to include the just completed entry.  When I press the submit button, it simply reloads the same page.  You can see the code above from the files I pasted yesterday.  What are your thoughts as to what's going on now?
umm are you sure it's a problem with your connection..

>>The error meassage was:
>>[Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot find the >>input table or query 'Tracking'. Make sure it exists and that its name is spelled correctly.

the error message is suggesting the the TABLE tracking does not exist....do you have such a table in your database..
maybe that the problem?
Ghost
Avatar of timjg

ASKER

Point well taken...the database is called TRACKING, the table within is called Daily_Tracking.  So I changed the SQL code in TrackingDataBean to the table name...but the same error occurs and it still says it's looking for Tracking.  What do you think?
:) you know when this sort of thing happens to me I'd just make a copy of that database and place it in every folder you have. It's supposed to go in one of them. So just made 6 copies and shove it everywhere.. and test that. if it works then take them out one at a time testing along the way to find out where it's really supposed to go..

that's what I would do it I were you.
let me know,
Ghost
Avatar of timjg

ASKER

That worked...as it turns out the jsp directory was correct.  I did copy it into all of them and take them out one by one but I also stopped and restarted the Web server so maybe that was the reason.  Well, step by step.  Now the JSP view page loads fine but when I enter data on the form generated by the JSP login page andpress submit, nothing is added to the database and I'm not forwarded to the JSP view page.  I've not completed all the code for the complete form on either the JSP login or view page but it should still show me what I'm asking for from the table, correct?  It seems that it's not even placing the data in the database.  What do you suggest now?
ummm maybe I'm wrong but...
  // return an ArrayList of TrackingBeans
  public ArrayList getTrackingList() throws SQLException
  {
      ArrayList trackingList = new ArrayList();
     
      // obtain list of titles
     
       
      ResultSet results = stat.executeQuery(
          "SELECT branch, year, month, day FROM Tracking" );
         
         
     
      // get row data
      while ( results.next() ) {
          TrackingBean tracking = new TrackingBean();
         
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
         
          trackingList.add( tracking );
      }
     
      return trackingList;
     
  }
 
  // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" );
  }    


does this mean that you are getting the values from the database...and then setting them into your object and then placing the same row back into your database?

cause that doesn't make sense..
I would check to see what's happening to the database..
see if the data is being added..if it's not print out your sql query and see if it's doing what you want it to be doing... cause that's the only way
Ghost
actually scrap that last post:

>>does this mean that you are getting the values from the database...and then setting them into >>your object and then placing the same row back into your database?

I just realised what you are doing..
but I would still check to see what's happening to the database..
see if the data is being added..if it's not print out your sql query and see if it's doing what you want it to be doing... cause that's the only way
Ghost
Add some println() debug statements to your bean to give an indication whats going on.
Avatar of timjg

ASKER

OK...dumb question, I think.  Nothing is being added to the database via the JSP, so how can I test the query outside of that?  The database is empty.  Is that affecting this?

As for the logic, here it is:  TrackingDataBean method getTrackingList returns an ArrayList of TrackingBean ogjects representing the tracking (rows) in the database.  Method getTrackingList creates the TrackingBean objects from the ResultSet returned by Statement method executeQuery.  TrackingDataBean method addTracking receives a TrackingBean as an argument and uses the TrackingBean's properties as the arguments to Statment method executeUpdate.  This Statement inserts a new tracking row in the database.  Does this make sense?      
Avatar of timjg

ASKER

Sorry just posted this before I saw your most recent comments.  However, can you still answer the sql question?
ok
>>TrackingDataBean method addTracking receives a TrackingBean as an argument and uses the >>TrackingBean's properties as the arguments to Statment method executeUpdate.

this is your insert...do this..

public void addTracking( TrackingBean tracking ) throws SQLException {
      String sqlQuery = "INSERT INTO tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" ;

      System.out.println(sqlQuery);

      stat.executeUpdate(sqlQuery);
  }    

Now if I'm not mistaken...the system.out statment will get send to your LiteWebServer..
Post the sqlQuery; and that will give us an indication of what's going on.
Ghost
> so how can I test the query outside of that?

yes, use whatever interface your dmbs provides to enter queries

> The database is empty.  Is that affecting this?

no

what is your table definition?
Are all those column strings? if not then they shouldn't be quoted in query.
Just for curiousity..does it matter if You quote fields even if they are not Strings? or does that depend on the database. cause I know it makes no difference using a mysql database.
or am I wrong?
Ghost
Avatar of timjg

ASKER

Alright, all of the fields are character fields so I'm assuming I can insert and display any or all of them.  I tried your modified addTracking method but nothing different happened.  The example I'm modeling this from only asks for three fields and says that the login page is loaded, once submitted reloaded to allow any empty fields to be filled and once all are filled it forwards to the JSP view page.  For the sake of making sure the logic worked I haven't completed the code for all the fields from the table in the JSP login or view pages but in the TrackingBean java file, I placed code only for the four fields that I have in the SQL statements.  Is this making the difference?  When I click submit the first time on the JSP login page, it reloads but has reset the four fields I filled.  

So should I finish the coding for the rest of the fields or comment out all but the four fields or is something else going on?

Thanks so much for your help.
> does it matter if You quote fields even if they are not Strings?

some db's will ceryainly complain, may be ok for others though.
I guess you should comment out everything that might damage it.. I wouldn't see why...but might as well try it..

use javascript for the vaildatoin that's the easiest to do.
if you used my modified code..then you should have got a printout of the sql statement..
post that please.
Ghost
>some db's will ceryainly complain, may be ok for others though.
good to know
thanks
Avatar of timjg

ASKER

I didn't get a printout and I'm wondering whether it's because the code is not complete for all the fields.  So, I'll comment out and try again.  Stay tuned...
Avatar of timjg

ASKER

Well, that didn't make any difference.  I commented out the HTML for the other fields in the JSP login and view pages but the same thing happens.  The form action in the JSP login page is the login page.  Is that correct?
well that depends...

the page is going to be sent to itself...is that what you want?
ghost
Avatar of timjg

ASKER

The example I'm modeling this after says that this is done so that all fields are filled.  It will only load that page agin if some fields are not filled.  And there's still no SQl printouts so should I revert back to the original addTracking method?  Since all the fields are filled is there something else going on?
Does trackingView.jsp get displayed after (failed) add?
well the version of my addTracking is the same has yours funtionally speaking..

umm the sql printout will not appear on the screen of anything it will appear on the server..so your litewebserver.. I've never used that server.. I normally use tomcat so I know that one.. but I do know that it is being printed out somewhere..are you sure that method is being called?

umm you're javascript should made sure that everything is valid you should not have the form action be the same... do something like this..

<form action="nextpage.jsp" method="post" onSubmit="checkValid();" name="myform">
      <input type="text" name="userName" />
//ADD OTHER FIELDS HERE
      <input type="submit" name="submit" value="Send to database" />
</form>

your js should look like this..
function checkValid() {
   if(document.myform.userName.value == ""){
      window.alert("Please enter a valid userNamenumber.");
      document.myform.userName.focus();
      return false;
   }

//ADD OTHER FIELDS HERE
}

something like that ...
you get the idea...
Ghost
Avatar of timjg

ASKER

There are log files which I've looked in in LWS but I don't see anything there or elsewhere.  Where in Tomcat is it stored?  This server is based on Tomcat so may be similar.
it's called the console monitor..
if you right click on the tomcat icon on the system tray it's one of the options..
anyways I hope that helps.. If not I'll try to help out tomorrow.
Cheers,
Ghost
Does trackingView.jsp get displayed after (failed) add?
Avatar of timjg

ASKER

objects...no the JSP view page doesn't display but I looked at the code again and the validation is in an IF statment outside of the HTML that checks for NULL values and then forwards to the view page if there are no NULLs so my earlier thought about commneting out HTML doesn't matter so I'm removing those.

Ghost...thanks for all your help today.  I'll keep plugging and you'll probably hear from me tomorrow.
> no the JSP view page doesn't display

Then from the look of your code the addTracking() method is not getting called.

> <jsp.setProperty name = "tracking" property = "*" />

try making that jsp:set

<jsp:setProperty name = "tracking" property = "*" />

Avatar of timjg

ASKER

Your suggestion for a new jsp:set looks identical to what I already have unless I'm missing something.

>Then from the look of your code the addTracking() method is not getting called.

>> <jsp.setProperty name = "tracking" property = "*" />

>try making that jsp:set

><jsp:setProperty name = "tracking" property = "*" />
you have a dot instead of a colon

should be "jsp:set...", not "jsp.set..."
Avatar of timjg

ASKER

thanks...I've been looking at this too long  :-(
Avatar of timjg

ASKER

What a difference a colon makes..the input is accepted, the JSP view page is loaded showing what I entered BUT there is nothing in the database.  Any idea what's going on there?
At a guess the insert is failing. Check the return value of executeUpdate() to see how many rows were added
Avatar of timjg

ASKER

Here's the executeUpdate.  I don't see a problem, but I didn't notice the period earlier...

 public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" );
     
  }
try this to check if insert failed:

 public void addTracking( TrackingBean tracking ) throws SQLException
  {
      int nrows = stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', + '" +
      tracking.getDay() + "' )" );
      if (nrows==0)
      {
          throw new SQLException("Insert failed");
      }
  }
Avatar of timjg

ASKER

No exception, and as it turns out I have a copy of the database within the Web server directory and my desktop.  It's been writing to the desktop copy!  Now I need to finish the code for the rest of the fileds in the database and fix the view page which is placing the rows one after another rather than side by side...

In case you're wondering, I'm giving you points as well as copyPasteGhost.  Without your help, I'd be sunk.

Stay tuned... I may have more questions and thanks a lot.
Good to hear you worked out the problem :)
Glad I can be of help
Ghost
Avatar of timjg

ASKER

Well, I thought I was out of the woods but another (I hope small) problem is occurring.  The JSP login file contains a Web form which has four option lists (which were the ones I had fully coded  to test the logic) and the rest of the fileds are text fields.  When I copied the same logic for the first of these text fields, it's adding NULL to the database and the subsequent JSP view page.  The fields in the database are all character fields.  Do the web form elements need to be something else or is something else going on?  The files above are principally the same as what I'm working with.  Thanks for any help you can provide.
Bit hard to determine the problem without seeing your code.
if I understand right.. You're text fields are working...but your select boxes are not?
if that right?
Ghost
Avatar of timjg

ASKER

Actually, it's just the opposite.  Select boxes are working.  Text boxes are not.
ok

if  you have this text field on one of the pages..

<table>
  <tr>
     <td>Postal Code/Zip Code</td>
     <td><input type="text" name="posZipCode" /></td>
  </tr>
</table>

and then on the other jsp page....the one were you add the stuff to the database you have to do this..

String posZipCode = request.getParameter("posZipCode")

//then you do you're database stuff here

String sqlQuery = (insert into table_name(zipCode) values ('" + posZipCode  + "'));

int result = statement.executeUpdate(sqlQuery);


This example should work...and you just have to add in all the other field names and that's about it...
anything else I can do for you?
Ghost
Avatar of timjg

ASKER

Here is the insert code from the DataBean file.  The last item (CheckingOpened) is where the problem is occurring.  The first four fields work fine.  Does this require a different solution than you're suggesting above?

 // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day, checking_opened ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', '" + tracking.getDay() + "', '" +
      tracking.getCheckingOpened() + "' )" );
     
  }
what does "tracking.getCheckingOpened() " return?

can you get a printout of the sql statement?

it looks good to me.. are you getting an error message or is NULL just being inserted in the "checking_opened" columun.

I think that this method "tracking.getCheckingOpened() " is returning a null....I'd check where are you setting something in the tracking object.
hope that helps,
Ghost
Avatar of timjg

ASKER

The method is placing a null in that column in the database which displays in the JSP view page.  I created a set and get method identical to the four fields which are the slect lists.  Here's the code:

 public class TrackingBean {

    private String branch, year, month, day, checking_opened, checking_closed, savings_opened, savings_closed;
    private String himm_accounts_opened, himm_new_money, himm_total_money, fs_appointments, fs_sales, fs_insurance_policies_sold;
    private String fc_appointments, fc_sales, installment_closed, equiline_closed, small_business_closed;
    private String installmnet_pipeline, equiline_pipeline, small_business_pipeline, cds_sold, cds_sales;
    private String loan_applications, credit_insurance_sold, internet_banking, visa_check_cards, weekly_regular_hours, weekly_ot_hours;
   
// set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
I think you are trying to add it to the database before putting something inside the object..

where are you setting the  checking_opened. meaning where is method "setCheckingOpened ( String co )" being called?

Ghost
can you post the jsp form
this might be wrong ...but maybe you're problem is a scope problem...
In here:
<!-- trackingLogin.jsp -->

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>

<%-- beans used in this JSP --%>
<jsp:useBean id = "tracking" scope = "page"
   class = "TrackingBean" />
<jsp:useBean id = "trackingData" scope = "request"
   class = "TrackingDataBean" />

try changing all the scopes to "page".. or even "session"....just to see if that will make a difference.. it shouldn't but maybe..
Ghost
Avatar of timjg

ASKER

Thanks again to both of you.  Here are all the app files as they are now...first the two java files and then the three jsp files:

rackingBean.java
// JavaBean to store branch sales data for a database

package trackPac;

public class TrackingBean {

    private String branch, year, month, day, checking_opened, checking_closed, savings_opened, savings_closed;
    private String himm_accounts_opened, himm_new_money, himm_total_money, fs_appointments, fs_sales, fs_insurance_policies_sold;
    private String fc_appointments, fc_sales, installment_closed, equiline_closed, small_business_closed;
    private String installmnet_pipeline, equiline_pipeline, small_business_pipeline, cds_sold, cds_sales;
    private String loan_applications, credit_insurance_sold, internet_banking, visa_check_cards, weekly_regular_hours, weekly_ot_hours;
    // private int
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
   
    /* set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }
   
    // set the branch's name
    public void setBranch ( String name )
    {
        branch = name;
    }
   
    // get the branch's name
    public String getBranch()
    {
        return branch;
    }    
   
    // set the branch's year
    public void setYear ( String yyyy )
    {
        year = yyyy;
    }
   
    // get the branch's year
    public String getYear()
    {
        return year;
    }
   
    // set the branch's month
    public void setMonth ( String mm )
    {
        month = mm;
    }
   
    // get the branch's month
    public String getMonth()
    {
        return month;
    }    
   
    // set the branch's day
    public void setDay ( String dd )
    {
        day = dd;
    }
   
    // get the branch's day
    public String getDay()
    {
        return day;
    }

    // set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }*/
}


// TrackingDataBean.java
// Class TrackingDataBean makes a database connection and supports
// inserting and retrieving data from the database/

package trackPac;

// Java core packages
import java.sql.*;
import java.io.*;
import java.util.*;


public class TrackingDataBean {
  private Connection connection;
  private PreparedStatement addRecord, getRecords;
  private Statement stat;
   
  // construct TitlesBean object
  public TrackingDataBean() throws Exception
  {
      //System.setProperty( "
     
      // load the Ability driver
      Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
     
      // connect to the database
      connection = DriverManager.getConnection(
          "jdbc:odbc:TRACKING" );
         
      //Statement stat=con.createStatement();
      //Statement stat=connection.createStatement();
      stat = connection.createStatement();
  }
 
  // return an ArrayList of TrackingBeans
  public ArrayList getTrackingList() throws SQLException
  {
      ArrayList trackingList = new ArrayList();
     
      // obtain list of titles
     
       
      ResultSet results = stat.executeQuery(
          "SELECT branch, year, month, day, checking_opened FROM Daily_Tracking" );
         
         
     
      // get row data
      while ( results.next() ) {
          TrackingBean tracking = new TrackingBean();
         
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );
          /*tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );
          tracking.setBranch( results.getString( 1 ) );
          tracking.setYear( results.getString( 2 ) );
          tracking.setMonth( results.getString( 3 ) );
          tracking.setDay( results.getString( 4 ) );
          tracking.setCheckingOpened( results.getString( 5 ) );*/
          trackingList.add( tracking );
      }
     
      return trackingList;
     
  }
 
  // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day, checking_opened ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', '" + tracking.getDay() + "', '" +
      tracking.getCheckingOpened() + "' )" );
     
  }    
     
  // close statemetns and terminate database connection
  protected void finalize()
  {
      // attempt to close database connection
      try {
          stat.close();
          connection.close();
      }
     
      // process SQLException on close operation
      catch ( SQLException sqlException ) {
          sqlException.printStackTrace();
      }
  }  
}


<?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- trackingLogin.jsp -->

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>

<%-- beans used in this JSP --%>
<jsp:useBean id = "tracking" scope = "page"
   class = "trackPac.TrackingBean" />
<jsp:useBean id = "trackingData" scope = "request"
   class = "trackPac.TrackingDataBean" />

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
    <title>Daily Sales Tracking</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   
    <style type="text/css">
   

    body {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
    }
   
    </style>
</head>

<body>
   <jsp:setProperty name = "tracking" property = "*" />

   <% // start scriplet

        if ( tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null /*||
             tracking.getCheckingOpened() == null
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getDay() == null */ ) {

   %> <%-- end scriptlet to insert fixed template data --%>

<table width="700" height="66" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="43"><div align="center"><img src="logo.jpg" alt="U.S. Bank - Five Star Service Guaranteed" width="175" height="48"></div></td>
  </tr></table>
<form action="trackingLogin.jsp" method="post">
  <table width="900" height="1136" border="0" align="center" cellpadding="2" cellspacing="2">
    <tr>
      <td height="50" colspan="6"> <div align="center"></h1> <strong>Please report
          sales activity for the previous business day</h1></strong> </div></td>
    </tr>
    <tr>
      <td height="50" colspan="6"> <div align="center"></h1> <strong>Branch name and date of activity are required</h1></strong> </div></td>
    </tr>
    <tr>
      <td colspan="2"> <div align="right"></div></td>
      <td width="15%"><div align="right">Branch: </div></td>
      <td width="24%"><select name="branch" size="1" id="branch">
          <option value="104th &amp; Federal">104th &amp; Federal</option>
          <option value="14th &amp; Taft">14th &amp; Taft</option>
          <option value="28th &amp; Quebec">28th &amp; Quebec</option>
        <option value="48th &amp; Tower">48th &amp; Tower</option>
          <option value="64th &amp; McIntyre">64th &amp; McIntyre</option>
          <option value="Arapahoe &amp; Parker">Arapahoe &amp; Parker</option>
        <option value="Castle Pines">Castle Pines</option>
          <option value="Castle Rock">Castle Rock</option>
          <option value="Chatfield &amp; Wadsworth">Chatfield &amp; Wadsworth</option>
        <option value="Cheyenne Meadows">Cheyenne Meadows</option>
          <option value="Englewood">Englewood</option>
          <option value="Harmony &amp; College">Harmony &amp; College</option>
        <option value="Louisville">Louisville</option>
          <option value="Miramonte">Miramonte</option>
          <option value="Monument">Monument</option>
        <option value="Nelson &amp; Hover">Nelson &amp; Hover</option>
          <option value="Parker">Parker</option>
        <option value="Powers &amp; Stetson">Powers &amp; Stetson</option>
          <option value="Pueblo">Pueblo</option>
          <option value="Sable &amp; Bromley">Sable &amp; Bromley</option>
        <option value="Smoky Hill">Smoky Hill</option>
          <option value="Thornton">Thornton</option>
        <option value="Wadsworth &amp; Jewel">Wadsworth &amp; Jewel</option>
          <option value="Wildcat Reserve">Wildcat Reserve</option>
          <option value="Windsor">Windsor</option>
        </select>
        </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Date of Sales Activity:</div>
        <div align="center"> </div></td>
      <td colspan="3"> <div align="left">
          <select name="year" size="1" id="year">
            <option value="Year">Year</option>
            <option value="2004">2004</option>
            <option value="2005">2005</option>
          <option value="2006">2006</option>
            <option value="2007">2007</option>
          </select>
         
          <select name="month" size="1">
            <option value="Month">Month</option>
            <option value="January">January</option>
            <option value="February">February</option>
            <option value="March">March</option>
          <option value="April">April</option>
            <option value="May">May</option>
            <option value="June">June</option>
            <option value="July">July</option>
          <option value="August">August</option>
            <option value="September">September</option>
            <option value="October">October</option>
            <option value="November">November</option>
          <option value="December">December</option>
          </select>
         
          <select name="day" id="day">
            <option value="Day">Day</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
          <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
          <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
          <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
          <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
            <option value="24">24</option>
            <option value="25">25</option>
          <option value="26">26</option>
            <option value="27">27</option>
            <option value="28">28</option>
            <option value="29">29</option>
            <option value="30">30</option>
          <option value="31">31</option>
          </select>
           </div></td>
    </tr>
     
    <tr>
      <td colspan="4"><div align="center"><strong>Loan Activity:</strong></div></td>
      <td colspan="2"><div align="center"><strong>DDA Activity:</strong></div></td>
    </tr>
    <tr>
      <td height="25" colspan="3"> <div align="right">Installment Closed ($):</div></td>
      <td><input type="text" name="installment_closed"></td>
      <td width="22%"><div align="right">Checking Opened:</div></td>
      <td width="24%"><input type="text" name="checking_opened"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Equiline Closed ($):</div></td>
      <td><input type="text" name="equiline_closed"></td>
      <td width="22%"><div align="right">Checking Closed:</div></td>
      <td width="24%"><input type="text" name="checking_closed"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Small Business Closed ($):</div></td>
      <td><input type="text" name="small_business_closed"></td>
      <td width="22%"><div align="right">Savings Opened:</div></td>
      <td width="24%"><input type="text" name="savings_opened"></td>
    </tr>
    <tr>
      <td colspan="4"><div align="center"><strong>Pipeline:</strong></div></td>
      <td width="22%"><div align="right">Savings Closed:</div></td>
      <td width="24%"><input type="text" name="savings_closed"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Installment ($):</div></td>
      <td><input type="text" name="installment_pipeline"></td>
      <td colspan="2"><div align="center"><strong>HIMM Accounts:</strong></div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Equiline ($):</div></td>
      <td><input type="text" name="equiline_closed"></td>
      <td><div align="right">Accounts Opened:</div></td>
      <td><input type="text" name="himm_accounts_opened"></td>
    </tr>
    <tr>
      <td height="39" colspan="3"> <div align="right">Small Business ($):</div></td>
      <td><input type="text" name="small_business_pipeline"></td>
      <td><div align="right">New Money ($):</div></td>
      <td><input type="text" name="himm_new_money"></td>
    </tr>
    <tr>
      <td height="28" colspan="4"> <p align="center"><strong>Promotional/Focus:</strong></p></td>
      <td><div align="right">Total Money ($):</div></td>
      <td><input type="text" name="himm_total_money"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">CDs Sold (#):</div></td>
      <td><input type="text" name="cds_sold"></td>
      <td colspan="2"><div align="center"><strong>Hours:</strong></div></td>
    </tr>
    <tr>
      <td height="33" colspan="3"> <div align="right">CDs Sales ($):</div></td>
      <td><input type="text" name="cds_sales"></td>
      <td><div align="right">Weekly Regular Hours:</div></td>
      <td><input type="text" name="weekly_regular_hours"></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Loan Applications (#):</div></td>
      <td><input type="text" name="loan_applications"></td>
      <td><div align="right">Weekly OT Hours:</div></td>
      <td><input type="text" name="weekly_OT_hours"></td>
    </tr>
    <tr>
      <td height="31" colspan="3"> <div align="right">Credit Insurance Sold (#):</div></td>
      <td><input type="text" name="credit_insurance_sold"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Internet Banking (#):</div></td>
      <td><input type="text" name="internet_banking"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">Visa Check Cards (#):</div></td>
      <td><input type="text" name="visa_check_cards"></td>
      <td colspan="2"><div align="center"><strong>When you're finished, please click Submit</strong></div></td>
    </tr>
    <tr>
      <td height="28" colspan="4"> <div align="center"><strong>Financial Specialist:</strong></div></td>
      <td colspan="2"><div align="center"><strong>Click Reset to re-enter</strong></div></td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FS Appointments (#):</div></td>
      <td><input type="text" name="fs_appointments"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FS Sales ($):</div></td>
      <td><input type="text" name="fs_sales"></td>
      <td> <div align="right"><input name="submit" type="submit" value="    Submit    " />        </div></td>
                  <td> <div align="left"><input type="reset" name="Reset" value="    Reset    ">        </div></td>      
    </tr>
    <tr>
      <td height="35" colspan="3"> <div align="right">FS Insurance Policies Sold
          (#):</div></td>
      <td><input type="text" name="fs_insurance_policies"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="29" colspan="4"> <p align="center"><strong>Financial Consultant:</strong></p></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FC Appointments (#):</div></td>
      <td><input type="text" name="fc_appointments"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="3"><div align="right">FC Sales ($):</div></td>
      <td><input type="text" name="fc_sales"></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td colspan="4">&nbsp;</td>
      <td colspan="2">&nbsp;</td>
    </tr> -->
  </table>
</form>

    <% //continue scriptlet

        } // end if
        else {
            trackingData.addTracking( tracking );

   %> <%-- end scriptlet to insert jsp:forward action --%>

        <%-- forward to display tracking contents --%>
        <jsp:forward page = "trackingView.jsp" />

   <% //continue scriptlet

        } // end else
   %> <%-- end scriplet --%>

</body>

</html>

<?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  >

<!-- trackingView.jsp -->

<%-- page settings --%>
<%@ page errorPage = "trackingErrorPage.jsp" %>
<%@ page import = "java.util.*" %>
<%@ page import = "trackPac.*" %>


<%-- TrackingDataBean to obtrain tracking list --%>
<jsp:useBean id = "trackingData" scope = "request"
    class = "trackPac.TrackingDataBean" />

<html xmlns = "http://www.w3.org/1999/xhtml">

    <head>
<title>Daily Sales Tracking</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">


body {
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
}

 table, tr, td, th {
                         text-align: center;
                        font-size: .9em;
                        border: 3px groove;
                        padding; 5px;
      }                  


</style>
</head>

<body>

<table width="1600" height="66" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="43"><div align="center"><img src="logo.jpg" alt="U.S. Bank - Five Star Service Guaranteed" width="175" height="48"></div></td>
  </tr></table>
<table>
<thead>
<tr>
<th></th>
<th>Activity Date:</th>
<th></th>
<th></th>
<th>DDA:</th>
<th></th>
<th></th>
<th></th>
<th>HIMM Accounts:</th>
<th></th>
<th></th>
<th>FS:</th>
<th></th>
<th></th>
<th>FC:</th>
<th></th>
<th>Loan Activity:</th>
<th></th>
<th></th>
<th>Pipeline:</th>
<th></th>
<th></th>
<th>Promotional/Focus:</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th>Weekly Hours:</th>
<th></th>
</tr>
<tr>
<th>Branch</th>
<th>Year</th>
<th>Month</th>
<th>Day</th>
<th>Checking Opened (#)</th>
<th>Checking Closed (#)</th>
<th>Savings Opened (#)</th>
<th>Savings Closed (#)</th>
<th>Accounts Opened (#)</th>
<th>New Money ($)</th>
<th>Total Money ($)</th>
<th>FS Appointments (#)</th>
<th>FS Sales ($)</th>
<th>FS Insurnace Policies Sold (#)</th>
<th>Appointments (#)</th>
<th>Sales ($)</th>
<th>Installment Closed ($)</th>
<th>Equiline Closed ($)</th>
<th>Small Business Closed ($)</th>
<th>Installment ($)</th>
<th>Equiline ($)</th>
<th>Small Business ($)</th>
<th>CDs Sold (#)</th>
<th>CDs Sales ($)</th>
<th>Loan Applications (#)</th>
<th>Credit Insurance Sold (#)</th>
<th>Internet Banking (#)</th>
<th>Visa Check Cards (#)</th>
<th>Branch Regular Hours Worked</th>
<th>Branch Overtime Hours Worked</th>
</tr>
</thead>

<tbody>

    <% // start scriptlet

        List trackingList = trackingData.getTrackingList();
        Iterator trackingListIterator = trackingList.iterator();
        TrackingBean tracking;

        while ( trackingListIterator.hasNext() ) {
            tracking = ( TrackingBean ) trackingListIterator.next();

   %> <%-- end scriptlet; insert fixed template data --%>

<tr>
<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
<!-- <td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td> -->
  </tr>                  
      
      
    <% //continue scriptlet

        } // end while

   %> <%-- end scriptlet --%>

</tbody>
</table>
</body>
</html>

<?xml version = "1.0"?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- trackingErrorPage.jsp -->

<%-- page settings --%>
<%@ page isErrorPage = "true" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.sql.*" %>

<html xmlns = "http://www.w3.org/1999/xhtml">

<head>
<title>Error!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
    .error


{
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 12px;
      color: #660033;
}

</style>
</head>

<body>
    <p class = "error">

    <% // scriptlet to determine exception type
       // and output beginning of error message
       if ( exception instanceof SQLException ) {
    %>

        An SQLException

    <%
        } else if (exception instanceof ClassNotFoundException ) {
    %>    
     
        A ClassNotFoundException

    <%
        } else {
    %>

        An exception

     <%
        }
     %>

    <%-- end scriptlet to insert fixed template data --%>

        <%-- continue error message output --%>
        occurred while entering data in the tracking database.

    </p>

    <p class = "error">
        The error meassage was:<br />
        <%= exception.getMessage() %>
    </p>

    <p class = "error">Please try again later.</p>
    </body>

</html>
   
I found something...In this file..

<!-- trackingLogin.jsp -->
   <jsp:setProperty name = "tracking" property = "*" />

   <% // start scriplet

        if ( tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null /*||                  SHOULD THE COMMENT BE HERE????? YOU       tracking.getCheckingOpened() == null             ARE NOT TESTING IF "tracking.getCheckingOpened
             tracking.getBranch() == null ||          () == null "
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getDay() == null */ ) {


maybe change this part to :


if ( tracking.getBranch() == null ||
             tracking.getYear() == null ||
             tracking.getMonth() == null ||
             tracking.getDay() == null ||
             tracking.getCheckingOpened() == null)

try that.
Ghost
> <td width="24%"><input type="text" name="checking_opened"></td>

think this should be:

<td width="24%"><input type="text" name="checkingOpened"></td>
good spot. I missed that
ghost
Avatar of timjg

ASKER

Ghost...Ive moved the comment mark so it does check that field but it makes no difference, still enters NULL in the database.

Objects...the field name in database is checking_opened, method is CheckingOpened.
The string varaible in the TrackingBean file is checking_opened, the set string variable is co.
The name of the text filed in the JSP is checking_opened.

This follows the very same pattern as the select boxes in the JSP, the only difference I can see is that it is a different form object.

Does that help?
umm you must change the name to this:

<td width="24%"><input type="text" name="checkingOpened"></td>

as objects says the reason is this...

<jsp:setProperty name = "tracking" property = "*" />

since you are using this line all the names of your form items must match the method names in the bean.
That's the only one that I can see that does not match and that's why you are getting the null.
I think at least..

try changing that and see what happens.
Ghost
> This follows the very same pattern as the select boxes in the JSP

Not that I can see.
eg. select box name is "month", method is setMonth()
Avatar of timjg

ASKER

OK...I changed the form item name to Checking_Opened, recompiled, load the jsp, and here are the results of the submit:

An exception occurred while entering data in the tracking database.

The error meassage was:
Unable to compile class for JSP An error occurred at line: -1 in the jsp file: null Generated servlet error: [javac] Compiling 1 source file [javac] C:\Program Files\lws-3.0.3\work\_\lws-standalone\tracking\jsp\trackingView_jsp.java:254: cannot resolve symbol [javac] symbol : method getCheckingOpened () [javac] location: class trackPac.TrackingBean [javac] out.print( tracking.getCheckingOpened() ); [javac] ^ [javac] C:\Program Files\lws-3.0.3\work\_\lws-standalone\tracking\jsp\trackingView_jsp.java:269: cannot resolve symbol [javac] symbol : method getCheckingOpened () [javac] location: class trackPac.TrackingBean [javac] out.print( tracking.getCheckingOpened() ); [javac] ^ [javac] C:\Program Files\lws-3.0.3\work\_\lws-standalone\tracking\jsp\trackingView_jsp.java:284: cannot resolve symbol [javac] symbol : method getCheckingOpened () [javac] location: class trackPac.TrackingBean [javac] out.print( tracking.getCheckingOpened() ); [javac] ^ [javac] C:\Program Files\lws-3.0.3\work\_\lws-standalone\tracking\jsp\trackingView_jsp.java:299: cannot resolve symbol [javac] symbol : method getCheckingOpened () [javac] location: class trackPac.TrackingBean [javac] out.print( tracking.getCheckingOpened() ); [javac] ^ [javac] C:\Program Files\lws-3.0.3\work\_\lws-standalone\tracking\jsp\trackingView_jsp.java:314: cannot resolve symbol [javac] symbol : method getCheckingOpened () [javac] location: class trackPac.TrackingBean [javac] out.print( tracking.getCheckingOpened() ); [javac] ^ [javac] 5 errors

Please try again later.

It continues to reference getCheckingOpened even though I changed it to getChecking_Opened.

What do you think?
Avatar of timjg

ASKER

Objects...isn't select box name month, method getMonth
and text box name checking_opened and method getChecking_Opened the same pattern?  In the above post I changed the method name to getChecking_Opened and the text box name to Checking_Opened and got the error above.

Perhaps I didn't think out naming well before I built this...

What do you think?
no don't do that...change it back..
the only line that you should change is this one..

now it's this in the file <!-- trackingLogin.jsp -->

>><td width="24%"><input type="text" name="checking_opened"></td>

change it to

<td width="24%"><input type="text" name="checkingOpened"></td>

don't change anything else..
and it should work..
Ghost
Avatar of timjg

ASKER

before I try this just to be clear...

database field name is checking_opened
method name is getChecking_Opened
form text name is checkingOpened

correct?
database field name is checking_opened
method name is getCheckingOpened
form text name is checkingOpened

 :) the method name and the text name must be the same...
the database name doesn't matter
Ghost
Avatar of timjg

ASKER

Tthat didn't make a difference (unless I missed something), I still get a NULL.  : - (  Here are the code snippets:

// set the branch's checking_opened
    public void setCheckingOpened ( String co )
    {
        checking_opened = co;
    }
   
    // get the branch's checking_opened
    public String getCheckingOpened()
    {
        return checking_opened;
    }


 // insert a branch's tracking in tracking database
  public void addTracking( TrackingBean tracking ) throws SQLException
  {
      stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day, checking_opened ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', '" + tracking.getDay() + "', '" +
      tracking.getCheckingOpened() + "' )" );
     
  }

<tr>
      <td height="25" colspan="3"> <div align="right">Installment Closed ($):</div></td>
      <td><input type="text" name="installment_closed"></td>
      <td width="22%"><div align="right">Checking Opened:</div></td>
      <td width="24%"><input type="text" name="CheckingOpened"></td>
    </tr>


<td><%= tracking.getBranch() %></td>
<td><%= tracking.getYear() %></td>
<td><%= tracking.getMonth() %></td>
<td><%= tracking.getDay() %></td>
<td><%= tracking.getCheckingOpened() %></td>
small difference..

>><td width="24%"><input type="text" name="CheckingOpened"></td>

should be

<td width="24%"><input type="text" name="checkingOpened"></td>

Lower case "c"

it's only this value that's returning null right?
Ghost

Avatar of timjg

ASKER

Why?  isn't it suppose to match the method name?

Of the five fileds I've tested, it's the only one retruning NULL.  Gotta get this one right before I finish it.
well that is matching the method name.
that's how jsp beans work..
try it.. hope it works..
if not then I'll look at it tomorrow..
cheers,
Ghost
Avatar of timjg

ASKER

It didn't work...catch you tomorrow.  Thanks again.
um  if I were you I would try to clean up your code... for instance you have entire sections commented out.. that makes reading the code hard..

maybe while cleaning it up you'll notice something that I missed.
Ghost

I'll take a better look later on and get back to you.
Also add some println debug statements to the methods involved to see what is actually being called.
Avatar of timjg

ASKER

Good news...whatever we did last night must have worked.  This morning I shut everything down, restarted and it worked.  So I'm adjusting the remaining code and am hoping for the best.  If I run into a problem, I'll let you know.

Thanks again.
Good thing cause I was starting to go crazy right along with you. That was the only possible thing that I saw that could have been wrong. Sometimes the answer is just restarting your web server especially when dealing with beans.. that's always an important thing to keep in mind.. whenever you make a change to a bean you should always restart sometimes you don't have to, but it's better to be safe then sorry.
glad it's all working!
Cheers,
Ghost
Excellent news :)
Avatar of timjg

ASKER

Alas, it looks like I ahve one last problme.  I'm getting an SQL error in the INSERT statement.  I've lloked at it and cna't seem to find anytning.  Can you?

Here it is:

stat.executeUpdate( "INSERT INTO Daily_Tracking ( branch, " +
      "year, month, day, checking_opened, checking_closed, savings_opened, savings_closed, himm_accounts_opened, himm_new_money, himm_total_money, fs_appointments, fs_sales, fs_insurance_policies_sold, fc_appointments, fc_sales, installment_closed, equiline_closed, small_business_closed, installment_pipeline, equiline_pipeline, small_business_pipeline, cds _sold, cds_sales, loan_applications, credit_insurance_sold, internet_banking, visa_check_cards, weekly_branch_hours, weekly_ot_hours ) VALUES ( '" + tracking.getBranch() + "', '" +
      tracking.getYear() + "', '" + tracking.getMonth() + "', '" + tracking.getDay() + "', '" + tracking.getCheckingOpened() + "', '" + tracking.getCheckingClosed() + "', '" + tracking.getSavingsOpened() + "', '" + tracking.getSavingsClosed() + "', '" + tracking.getHimmAccountsOpened() + "', '" + tracking.getHimmNewMoney() + "', '" + tracking.getHimmTotalMoney() + "', '" + tracking.getFsAppointments() + "', '" + tracking.getFsSales() + "', '" + tracking.getFsInsurancePoliciesSold() + "', '" + tracking.getFcAppointments() + "', '" +
      tracking.getFcSales() + "', '" + tracking.getInstallmentClosed() + "', '" + tracking.getEquilineClosed() + "', '" + tracking.getSmallBusinessClosed() + "', '" + tracking.getInstallmentPipeline() + "', '" + tracking.getEquilinePipeline() + "', '" + tracking.getSmallBusinessPipeline() + "', '" + tracking.getCdsSold() + "', '" + tracking.getCdsSales() + "', '" + tracking.getLoanApplications() + "', '" + tracking.getCreditInsuranceSold() + "', '" + tracking.getInternetBanking() + "', '" + tracking.getVisaCheckCards() + "', '" + tracking.getWeeklyBranchHours() + "', '" +
      tracking.getWeeklyOtHours() + "' )" );
This is one of the reasons I always suggest to people to use PreparedStatements, as well as improving performance, and handling escaping for, they also make your code a lot more readable :)

Are all the columns being inserted char types?
Avatar of timjg

ASKER

They are and this statement was working until I added all the additional fields.  I've run the SQL in my database but it simply tells me there's an error in the statement, no other clues.
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
was there anything else I could help you with? cause if not you should close this question.
Ghost
Avatar of timjg

ASKER

Sorry guys, I was able to get the app working thanks to your help and have been overwhelmed at work since so this is my first opportunity to close this.  I will do so and give both of you points as I agreed.  However, I wanted to award more than 500 points to this as I had originally allotted.  Is there a way to do this?
well what other people do is they just open a question and then say points for help with ...and then they add the url to this question so in this case in would be.

points for help with https://www.experts-exchange.com/questions/20925914/Beans-files-errors.html

Something like that,
Glad I could help,
Ghost
thanks for the points,
Ghost
Avatar of timjg

ASKER

Ghost...here's the link for the additional points:

https://www.experts-exchange.com/questions/20940878/Points-for-helping-with-Beans-files-errors.html

Please post a comment there and I will give you the rest of the points.  Thanks again.