0

Hello, thanks for your time.

Jsp + javaBean will not run in tomcat on local host http://localhost:8080/is/scannerForm/process.jsp, when i run it in eclipse though my local tomcat it actually does work and i can step through the jsp page as-well as the .java pages and i can see where they are saving variables into the bean and all is working with no errors. When it gets to the method in the bean to submit the accessed data to a oracle database(InsertmainElement()) the connection succeeds and it does submit though eclipse but when run by http://localhost:8080/is/scannerForm/process.jsp it will not submit to the data base. but will not generate any errors, checked tomcat logs not much there can be posted if it will help. Ive been stuck on this for a few days now.

:-/Anyone can help would be greatly appreciated.


main jsp page(form)
process.jsp

<!-- fandp manufacturing -->
<!-- author:bryn flewelling,date:2011.1.13 -->
<%@ page language="java" contentType="text/html"%>
<%@ page import="java.util.ArrayList" %>
<%@ page import="scannerForm.DataAccess" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="scannerForm.FormDataBean" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<jsp:useBean id="formbean" scope="application" class="scannerForm.FormDataBean">
<jsp:setProperty name="formbean" property="swipeCard"/>
<jsp:setProperty name="formbean" property="workArea"/>
<jsp:setProperty name="formbean" property="partNumber"/>
<jsp:setProperty name="formbean" property="quantity"/></jsp:useBean>
<head>
<title>Scanner Form</title>
<link rel="icon" type="image/ico" href="images/logo1.ico" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<script type="text/javascript">
function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}
function validate_form(thisform)
{
with (thisform)
  {
  if (validate_required(swipeCard,"A valid card number must be entered.")==false)
  {swipeCard.focus();return false;}
  if (validate_required(workArea,"A  valid work area must be entered.")==false)
  {workArea.focus();return false;}
  if (validate_required(partNumber,"A valid part number must be entered.")==false)
  {partNumber.focus();return false;}
  if (validate_required(quantity,"A quantity value must be entered.")==false)
  {quantity.focus();return false;}
  }
}
function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
</script>
</head>
<body style="width:auto;height:auto;background-color:white;color:#333;text-align:center;font:90%">
<% if (request.getParameter("swipeCard") == null && request.getParameter("workArea") == null &&  request.getParameter("partNumber") == null && request.getParameter("quantity") == null ){ %>
<form id="1" method="get" action="process.jsp"  onsubmit="return validate_form(this);" style="width:auto;height:auto;border-style:solid;border-color:#F00;">
    <h2 style="text-align:center;">Scanner Form<br /><img id="image" src="images/logo.gif" href="images/logo.gif"/></h2>
    <hr> 
    <div style="width:auto;height:auto;margin-left:auto;margin-right:auto;">
		<p style="text-align:center;" class="intro">Swipe Card Number:</p>
	    	  <p><input type="text" name="swipeCard" property="swipeCard"/></p>
		<p for="workArea">Work Area: 
			<select name="workArea" id="workArea"  property="workArea" style="overflow:hidden;maxheight:10px;">
			<% 	
			DataAccess dataAccess = new DataAccess();
			ArrayList workAreas = dataAccess.loadWorkAreas();;
			Iterator it = workAreas.iterator();
			String xx = null;
			while(it.hasNext()) { 
			 xx = (String) it.next(); %>
			<option  name="workArea" id="workArea" value="<%=xx%>"><%=xx%></option>
			<% } %>
			</select></p>
	    <p>Part Number: </p>
	    	<p><input type="text" name="partNumber" property="partNumber"/></p>
	    <p>Quantity: </p>
	    	<p><input type="text" name="quantity" property="quantity"/></p>
	       <hr>
        <p><input type="submit" value="Process" /><input type="reset" /></p></div>
</form>
<% } else { %>
<form id="2" method="post" style="width:auto;height:auto;border-style:solid;border-color:#F00;">
<h2 style="text-align:center;">Scanner Form<br /><img id="image" src="images/logo.gif" href="images/logo.gif"/></h2>
<hr> 
<div style="width:auto;height:auto;margin-left:auto;margin-right:auto;">
<p>You have provided the following data:</p>
<p>Card Number: ${param.swipeCard}</p>
<p>Work Area: ${param.workArea}</p>
<p>Part Number: ${param.partNumber}</p>
<p>Quantity: ${param.quantity}</p>
<hr>
<p><input type="button" value="New Report" onclick="document.location = 'process.jsp';"/></p>
<p><input type="button" value="Exit" onclick="window.close()"/></p></div></form>
<% } %>     
</body>     
</html>

java bean
FormDataBean.java

package scannerForm;

import java.io.*;     
import java.sql.*;
import java.util.Map;
import java.util.*;
import downtime.ConnectionDataBase;

import jdbc_connect.conn;

/**
 * FandPMFG. This class is the Bean for the process.jsp page and submits the data to a store procedure.
 * 
 * @author  Bryn Flewelling
 * @version 2011.1.13
 */
public class FormDataBean implements Serializable  { 

	public static String ColumnsNames = "user_id, workarea, storeroom_part_number, quantity, created_date, created_by";	
	public static String jdbc_connection = "dcs_fp";		
	conn conn_fandp = null;
	//fields
	protected String swipeCard;
	protected String workArea;     
	protected String partNumber; 
	protected String quantity; 
	//constructor
	public FormDataBean() {  
		//for testing purposes...
		//swipeCard = "5";   
		//workArea = "4";  
		//partNumber = "6";
		//quantity = "4";
		//loadValues();
		//form validation
		swipeCard = null;   
		workArea = null;  
		partNumber = null;
		quantity = null;
	}     
	/**
	 * Sets the value of the swipeCard using the process.jsp property values.
	 * 
	 * @param swipeCard,   Sets the input value of the form to swipeCard.
	 */
	public void setSwipeCard(String swipeCard) {     
		this.swipeCard = swipeCard; 
		System.out.println("Card Number: " + swipeCard);
	}     
	/** 
	 * Gets the value of the swipeCard.
	 * @return swipeCard, returnes the value of the swipeCard.
	 */
	public String getSwipeCard() {  
		return swipeCard;     
	}   
	/**
	 * Sets the value of the workArea using the process.jsp property values.
	 * 
	 * @param workArea,   Sets the input value of the form to workArea.
	 */
	public void setWorkArea(String workArea) {     
		this.workArea = workArea; 
		System.out.println("Work Area: " + workArea);
	}     
	/** 
	 * Gets the value of the workArea
	 * @return workArea, returnes the value of the workArea.
	 */
	public String getWorkArea() {  
		return workArea;     
	}   
	/**
	 * Sets the value of the partNumber using the process.jsp property values.
	 * 
	 * @param partNumber,   Sets the input value of the form to partNumber.
	 */
	public void setPartNumber(String partNumber) {     
		this.partNumber = partNumber;   
		System.out.println("Part Number: " + partNumber);
	}     
	/** 
	 * Gets the value of the partNumber.
	 * @return partNumber, returnes the value of the partNumber.
	 */
	public String getPartNumber() {     
		return partNumber;     
	} 
	/**
	 * Sets the value of the quantity using the process.jsp property values.
	 * 
	 * @param quantity,   Sets the input value of the form to quantity
	 */
	public void setQuantity(String quantity) {     
		this.quantity = quantity;   
		System.out.println("Quantity: " + quantity);
		InsertmainElement();
		//InsertRecord();
		System.out.println("=========================");
		loadValues();
	}     
	/** 
	 * Gets the value of the quantity.
	 * @return quantity, returnes the value of the quantity.
	 */
	public String getQuantity() {     
		return quantity;     
	}       
	/**
	 * Loads the values of the variables.
	 */
	public void loadValues(){
		System.out.println("Card Number: " + swipeCard + " size = " + swipeCard.length());
		System.out.println("Work Area: " + workArea + " size = " + workArea.length());
		System.out.println("Part Number: " + partNumber + " size = " + partNumber.length());
		System.out.println("Quantity: " + quantity + " size = " + quantity.length());
	}
	public void dumpEnv(){
		try {
			System.out.println(" ENV = " + System.getenv());
		
		Map envVars =  System.getenv();
		//Get Map in Set interface to get key and value
        Set set = envVars.entrySet();

        //Move next key and value of Map by iterator
        Iterator it=set.iterator();
        System.out.println("Date Time Bryn " + new java.util.Date());
        while(it.hasNext()) {
        	//System.out.println("pickles");
            // key=value separator this by Map.Entry to get key and value
            Map.Entry m =(Map.Entry)it.next();

            // getKey is used to get key of Map
            Object property =(String)m.getKey();
            
            // getValue is used to get value of key in Map
            String value=(String)m.getValue();

            System.out.println("Property :"+property.toString()+"  Value :"+value + "\n"); 
        }
        } catch (Exception e) {
        	System.out.println("error processing" + e.getMessage());
        }
	}
	/**
	 * Truncates s to fit within len. If s is null, null is returned.
	 **/
	public String truncate(String s, int len) { 
	  if (s == null) return null;
	  return s.substring(Math.min(len, s.length()));
	}
	/** 
	 * Makes a database connection and calls a store procedure with the variables.
	 * @return bln_result, returnes true is database connection has succeded and false if it has failed.
	 */
	public boolean InsertmainElement()
	{
		boolean bln_result = true;
		dumpEnv();
		conn_fandp = new conn();
		
		bln_result = conn_fandp.getConnection(jdbc_connection);		       

		if (bln_result == false)  {
			System.out.println("Connection to DCS FANDP schema failed.");
			return false;
		}
		else {
			System.out.println("Connection to DCS FANDP succeded.");   
			loadValues();
		}           
		try {	
			// this will call the store procedure
			Connection curr_conn  = conn_fandp.current_connection;		
			//loadValues();
			
			//String to integer conversion
			Integer qty = Integer.parseInt(quantity);
			
		    /*String value = "_";
			if (swipeCard != null && swipeCard.length() > 0) {
			  value = truncate(swipeCard, 36);
			}
			String value1 = "_";
			if (workArea != null && workArea.length() > 0) {
			  value1 = truncate(workArea, 36);
			}
			String value2 = "_";
			if (partNumber != null && partNumber.length() > 0) {
			  value2 = truncate(partNumber, 36);
			}
			String value3 = "_";
			if (quantity != null && quantity.length() > 0) {
			  value3 = truncate(quantity, 36);
			}*/
			
			//String procedure="{call fandp.p_strm_scanner (?,?,?,?)";
			//String procedure="{call fandp.p_strm_scanner('swipeCard', 'workArea', 'partNumber3', 1, 'user')}";
			//p_strm_scanner('userID', 'workArea', 'partNumber3', 1)
			//CallableStatement cs = curr_conn.prepareCall(procedure.toString());
			//cs.setString(1,swipeCard);
			//cs.setString(2,workArea);
			//cs.setString(3,partNumber);
			//cs.setInt(4,qty);
			//cs.setString(5, "");
			//cs.setString(1,value);
			//cs.setString(2,value1);
			//cs.setString(3,value2);
			//cs.setInt(4,value3);
			//cs.execute();
			
			System.out.println(" Commit mode = " + curr_conn.getAutoCommit());
			curr_conn.setAutoCommit(true);
			System.out.println(" Commit mode = " + curr_conn.getAutoCommit());
			curr_conn.prepareCall("{call fandp.p_strm_scanner('"+swipeCard+"','"+workArea+"','"+partNumber+"',"+qty+")}").execute();
			
			//curr_conn.prepareCall("{call fandp.p_strm_scanner('"+value+"','"+value1+"','"+value2+"','"+value3+"')").execute();
			//rs = curr_conn.createStatement().executeQuery(sql);

			//	rs.close();
			curr_conn.close();	

		}catch(Exception e) {
			// bln_result = false;
			System.out.println(e);
		}
		conn_fandp.current_connection = null;			     	
		conn_fandp = null;
		//for testing purposes...
		//formData.add(swipeCard);
		//formData.add(workArea);
		//formData.add(partNumber);
		//formData.add(quantity);
		return bln_result;
	}	
}

tom cat stdout logfile

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
java.util.logging.ErrorManager: 1
java.lang.NullPointerException
	at org.apache.juli.FileHandler.publish(FileHandler.java:137)
	at java.util.logging.Logger.log(Unknown Source)
	at java.util.logging.Logger.doLog(Unknown Source)
	at java.util.logging.Logger.logp(Unknown Source)
	at org.apache.commons.logging.impl.Jdk14Logger.log(Jdk14Logger.java:91)
	at org.apache.commons.logging.impl.Jdk14Logger.info(Jdk14Logger.java:162)
	at org.apache.coyote.http11.Http11AprProtocol.pause(Http11AprProtocol.java:163)
	at org.apache.catalina.connector.Connector.pause(Connector.java:1032)
	at org.apache.catalina.core.StandardService.stop(StandardService.java:489)
	at org.apache.catalina.core.StandardServer.stop(StandardServer.java:734)
	at org.apache.catalina.startup.Catalina.stop(Catalina.java:602)
	at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:645)
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
java.util.logging.ErrorManager: 1
java.lang.NullPointerException
	at org.apache.juli.FileHandler.publish(FileHandler.java:137)
	at java.util.logging.Logger.log(Unknown Source)
	at java.util.logging.Logger.doLog(Unknown Source)
	at java.util.logging.Logger.logp(Unknown Source)
	at org.apache.commons.logging.impl.Jdk14Logger.log(Jdk14Logger.java:91)
	at org.apache.commons.logging.impl.Jdk14Logger.info(Jdk14Logger.java:162)
	at org.apache.coyote.http11.Http11AprProtocol.pause(Http11AprProtocol.java:163)
	at org.apache.catalina.connector.Connector.pause(Connector.java:1032)
	at org.apache.catalina.core.StandardService.stop(StandardService.java:489)
	at org.apache.catalina.core.StandardServer.stop(StandardServer.java:734)
	at org.apache.catalina.startup.Catalina.stop(Catalina.java:602)
	at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:645)
log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
Connection to DCS FANDP succeded.
Iterating through ArrayList elements...
Iterations:1WCFL
Iterations:1WCSF
Iterations:1WCSN
Iterations:1WCTN
Iterations:2WCSF
Iterations:AAAP
Iterations:AACO
Iterations:AAGV
Iterations:AAL1
continued..

i also have another class called DataAccess that populates the drop down on the process.jsp page. This page works all the time when i run it in eclipse and in a browser and shows the gathered data but the DataFormBean is where the trouble is. Thanks

Edited by brynFlew: n/a

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by brynFlew
0

what i have come up so far

servlet(the generated servlet)needs to be executed and put in the xml, not the default jsp page.

or 2 instances of the tomcat server one in eclipse one in tomcat and wrong classpaths.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.