• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp and beans

 
priya ranjan sahay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

To Javaranch.com
We have been encountered with a problem during the execution of a jsp application program.
The following are the details of the problem that is encountered
1) Details of Application - what the application has to do:
Certain parameteres are to be inserted in the database through a html form that is present on the client browser.
2) The following are the class files that are created for this particular operation
a) DBConnect.java - path c:/jswdk-1.0.1/examples/jsp/book.
b) StockInput.java - path c:/jswdk-1.0.1/examples/jsp/book.
c) Insert.jsp - path c:/jswdk-1.0.1/examples/jsp/book.
and the file name of the .htm file is dataen.html - path c:/jswdk-1.0.1/examples/jsp/book.
We have created the database on oracle 8 and also the appropriate DSN is being given.
3) The error that we are getting is class not found, it is not recognising the path class examples.jsp.book.StockInput.
The error is 'class examples.jsp.book.StockInput not found'.

We are sending the code of all the java files and the htm file that is been created along with this mail.
Please rectnify this problem and kindly mail us back the solution.

The html code.
<html>
<!-- creation date: 3/17/2001 -->
<head>
<title>Data Entry Form</title>
<meta name="Description" content="">
<meta name="Keywords" content="">
<meta name="Author" content="Unregistered user">
<meta name="Generator" content="AceHTML 4 Freeware">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<H1 align = "CENTER" ><STRONG><EM>Book Entry Form </STRONG></EM></h1>
<HR WIDTH="100%">
<br>
<SCRIPT LANGUAGE="JavaScript">
<!-- begin script
var msgBan6, msgBan6b, string6 = "", stringPart6, delayBan6, ban6;
function banniere6(delay) {
delayBan6 = delay;
if (string6.length == 0) {
string6 = " ";
msgBan6b = msgBan6;
stringPart6 = "";
}
else if (string6.length == 1) {
while (msgBan6b.substring(0, 1) == " ") {
stringPart6 = stringPart6 + string6;
string6 = msgBan6b.substring(0, 1);
msgBan6b = msgBan6b.substring(1, msgBan6b.length);
}
stringPart6 = stringPart6 + string6;
string6 = msgBan6b.substring(0, 1);
msgBan6b = msgBan6b.substring(1, msgBan6b.length);
}
else string6 = string6.substring(10, string6.length);
window.status = stringPart6 + string6;
ban6 = window.setTimeout('banniere6(delayBan6)',delay);
}
function isEmpty(s)
{
var len=s.length
var i
for(i=0;i<len;i++)
{
if(s.charAt(i)!=" ") return false
}
alert("Please do not leave the field blank")
return true
}
function isNum2(s)
{
var i
if(!isEmpty(s))
{
for(i=0;i<s.length;i++)
{
var ch=s.substring(i,i+1)
if(ch<"0" | | ch>"9")
{
alert("Please enter the numberl")
//document.entry.ISBN.focus()
//document.entry.ISBN.select()
return false
}
}
if(document.entry.Y_PUB.value <1900)
{
alert("Please check your year of publication")
}
}
return true
}
function isNum1(s)
{
var i
if(!isEmpty(s))
{
for(i=0;i<s.length;i++)
{
var ch=s.substring(i,i+1)
if(ch<"0" | | ch>"9")
{
alert("Please enter the number")
//document.entry.ISBN.focus()
//document.entry.ISBN.select()
return false
}
}
}
return true
}
function isNumeric(s)
{
var i
if(!isEmpty(s))
{
for(i=0;i<s.length;i++)
{
var ch=s.substring(i,i+1)
if(ch<"0" | | ch>"9")
{
alert("Please enter the number")
//document.entry.ISBN.focus()
//document.entry.ISBN.select()
return false
}
}
}
return true
}
function isValidate()
{
if(isEmpty(document.entry.ISBN.value))return false
//if(!isNumeric(document.entry.ISBN.value))return false
if(isEmpty(document.entry.BOOK_TITLE.value))return false
if(isEmpty(document.entry.AUT.value))return false
if(isEmpty(document.entry.PUB.value))return false
if(isEmpty(document.entry.Y_PUB.value))return false
if(isEmpty(document.entry.PRICE.value))return false
if(isEmpty(document.entry.CATEGORY.value))return false
if(!isNum2(document.entry.Y_PUB.value))return false
if(!isNum1(document.entry.PRICE.value))return false
//return false
//isEmpty(document.entry.QTY.value);
}
// end script -->
</SCRIPT>
</head>
<BODY BGCOLOR="FF6347" onLoad="msgBan6='OnLineBookShopping !!!'; banniere6(100);" onUnload="clearTimeout(ban6)">
<FORM name=entry method=get action="insert.jsp" ONSUBMIT="return isValidate()"><B>
ISBN NUMBER :
<INPUT TYPE="TEXT" NAME="ISBN" SIZE="13" ONCHANGE="isNumeric(document.entry.ISBN.value)"><P>
BOOK TITLE:
<INPUT TYPE="TEXT" NAME="BOOK_TITLE" SIZE="40" ONCHANGE="isEmpty(document.entry.BOOK_TITLE.value)"><P>
AUTHOR:
<INPUT TYPE="TEXT" NAME="AUT" SIZE="40" ONCHANGE="isEmpty(document.entry.AUT.value)"><P>
PUBLICATION:
<INPUT TYPE="TEXT" NAME="PUB" SIZE="40" ONCHANGE="isEmpty(document.entry.PUB.value)"><P>
YEAR OF PUBLICATION:
<INPUT TYPE="TEXT" NAME="Y_PUB" SIZE="4" ONCHANGE="isNum2(document.entry.Y_PUB.value)"><P>
PRICE:
<INPUT TYPE="TEXT" NAME="PRICE" SIZE="10" ONCHANGE="isNum1(document.entry.PRICE.value)"><P>
CATEGORY:
<INPUT TYPE="TEXT" NAME="CATEGORY" SIZE="40" ONCHANGE="isEmpty(document.entry.CATEGORY.value)"><P>
DESCRIPTION:
<INPUT TYPE="TEXT" NAME="DESC" SIZE="40" ONCHANGE="isEmpty(document.entry.DESC.value)"><P>
<INPUT TYPE="SUBMIT" NAME="SUB" value="Insert" >
<INPUT TYPE="RESET">
<INPUT TYPE="BUTTON" NAME="CANC" VALUE="Cancel"></B></FORM>
</body>
</html>

The code for insert.jsp
<%@ page language="java" import ="java.sql.*" %>
<jsp:useBean id="empBean" class="/examples.jsp.book.StockInput" scope="page" />
<html>
<head></head>
<body>
<%
empBean.makeConnection();
String isbn=request.getParameter("ISBN");
String book=request.getParameter("BOOK_TITLE");
String aut=request.getParameter("AUT");
String pub=request.getParameter("PUB");
String ypub=request.getParameter("Y_PUB");
String pri=request.getParameter("PRICE");
String cat=request.getParameter("CATEGORY");
String des=request.getParameter("DESC");
empBean.DBInsert(isbn,book,aut,pub,ypub,pri,cat,des);
%>
</body>
</html>
The code for DBConnect.java
import java.sql.*;
import java.io.*;
public class DBConnect {
//private String my
protected Connection con;
public DBConnect(){}
public void makeConnection() throws Exception {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc dbc:emp1");
}
//public abstract void cleanup() throws Exception;
/*public void takedown() throws Exception {
cleanup();
con.close();*/
}

The code for StockInput.java
import java.io.*;
import java.sql.*;

public class StockInput extends DBConnect
{
protected Statement stmt;
public StockInput(){
}
public void DBInsert(String isbn,String title,String author,String pub,String ypub , String price,String category,String edi,String qty,String des)
{
try{
stmt=con.createStatement();
stmt.executeUpdate("insert into book_stock values(isbn,title,author,pub,Integer.parseInt(ypub),Integer.parseInt(ypub),category,edi,Integer.parseInt(qty),des)");
}catch(SQLException ex){}
}
}

Thank you
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Priya,
Forgot about jswdk, since currently I use Tomcat. But what I think is, the problem most probably lies in this line

Why did you put a forward slash in class="/examples.jsp.book...."?
The forward slash doesn't make sense there. Also this line means, your StockInput is in a package called examples.jsp.book, but in your StockInput.java there is no "package examples.jsp.book; " statement. Try to play around this line.

regds
maha anna
[This message has been edited by maha anna (edited March 26, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic