You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by yaya <ya...@supersiswa.com> on 2000/12/21 05:45:40 UTC

jsp bean error to find class

Hi,
I tried to connect to mysql database with bean but fail with following error
:
org.apache.jasper.JasperException: Unable to compile class for
JSP/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdataba
seselect_0002ejspdatabaseselect_jsp_0.java:64: Class jsp.DatabaseSelect not
found.
                DatabaseSelect select = null;
                ^
/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdatabases
elect_0002ejspdatabaseselect_jsp_0.java:67: Class jsp.DatabaseSelect not
found.
                    select= (DatabaseSelect)
                             ^
/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdatabases
elect_0002ejspdatabaseselect_jsp_0.java:72: Class jsp.DataBaseSelect not
found.
                            select = (DataBaseSelect)
Beans.instantiate(this.getClass().getClassLoader(), "DataBaseSelect");
                                      ^
3 errors

I already put DataBaseSelect.java & DataBaseSelect in
/usr/local/jakarta-tomcat-3.2.1/webapps/examples/WEB-INF/classes

Looks like it fail to find the class,..so where should I put the class file
?

This is the jsp files ( in
/usr/local/jakarta-tomcat-3.2.1/webapps/examples/jsp)
<html>
<head>
<title>Select everything from a database</title>
</head>
<body>

<jsp:useBean id='select' class='DataBaseSelect' scope='page'
type="DatabaseSelect" />

<% out.print(select.connect()); %>
<br>
<% out.print(select.select()); %>

<p>Format results

<br>
<%@ page import="java.util.Vector" %>
<% Vector aResult = select.getResult(); %>

<table>
<% for (int i=0; i < aResult.size(); i++) { %>
   <tr>
       <td>
           <% out.print(aResult.elementAt(i)); %>
       </td>
   </tr>
<% } %>
</table>

</body>
</html>

Thanks



Re: jsp bean error to find class

Posted by William Brogden <wb...@bga.com>.

yaya wrote:
> 
> Hi,
> I tried to connect to mysql database with bean but fail with following error
> :
> org.apache.jasper.JasperException: Unable to compile class for
> JSP/usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdataba
> seselect_0002ejspdatabaseselect_jsp_0.java:64: Class jsp.DatabaseSelect not
> found.
>                 DatabaseSelect select = null;
>                 ^
> /usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdatabases
> elect_0002ejspdatabaseselect_jsp_0.java:67: Class jsp.DatabaseSelect not
> found.
>                     select= (DatabaseSelect)
>                              ^
> /usr/local/jakarta-tomcat-3.2.1/work/localhost_8080/_0002fjsp_0002fdatabases
> elect_0002ejspdatabaseselect_jsp_0.java:72: Class jsp.DataBaseSelect not
> found.

I think the error message is trying to tell you that you have not
specified 
what DatabaseSelect is.

-- 
WBB - wbrogden@lanw.com
Java Cert mock exams http://www.lanw.com/java/javacert/
Author of Java Developer's Guide to Servlets and JSP 
ISBN 0-7821-2809-2

RE: my jsp updates with null values: SECURITY ???

Posted by Dave Newton <da...@solaraccess.com>.
> Have you ever wondered what will happen if someone entered
> a request with idnum something like
> '0,...,);DROP info CASCADE;

Whoops, missed your single quote. Sorry, you're right.

Dave


RE: my jsp updates with null values: SECURITY ???

Posted by ro...@zzict.nl.

On Thu, 21 Dec 2000, Dave Newton wrote:

> I remember you~it looks better with the variables not in the quotes.
> 
> > <%@page import="java.sql.*,javax.servlet.http.HttpServletRequest" %>
> > <%!
> > //Declare your variables;
> > String DRIVER  = "org.gjt.mm.mysql.Driver";
> > String CONNECT = "jdbc:mysql://127.0.0.1/userinfo";
> > String QUERY   = "insert into info
> > values('"+idnum+"','"+fname+"','"+lname+"','"+addr1+"','"+addr2+"'
> > ,'"+city+"
> > ','"+state+"','"+zip+"','"+phone1+"')";
> > %>
> > <%
> > //some debug code to see what the values of these fields are... (not
> > working)
> > out.println(idnum);
> > out.println(fname);
> > out.println(lname);
> > out.println(addr1);
> > out.println(addr2);
> > out.println(city);
> > out.println(state);
> > out.println(phone1);
> > %>
> > 
> > <% //get information from another page, and, if there is no 
> > information, set
> > the values to NULL
> > 
> >  String idnum = request.getParameter("idnum");
> >  String fname = request.getParameter("fname");
> >  String lname = request.getParameter("lname");
> >  String addr1 = request.getParameter("addr1");
> >  String addr2 = request.getParameter("addr2");
> >  String city = request.getParameter("city");
> >  String state = request.getParameter("state");
> >  String zip = request.getParameter("zip");
> >  String phone1 = request.getParameter("phone1");
> > 
> > %>
> 
> Is there any particular reason you set the values of the variables
> after you try to use them?
> 
> I think you'd be better off asking these questions in a java group,
> as this is a pretty straightforward error.
> 
> Dave
> 
Have you ever wondered what will happen if someone entered
a request with idnum something like
'0,...,);DROP info CASCADE;

right.

This brings us to the tip of the day:

USE PREPARED STATEMENTS OR FEAR THE WRATH OF THE WEB-HACKER.

have fun,
Sloot.


RE: my jsp updates with null values.

Posted by Dave Newton <da...@solaraccess.com>.
I remember you~it looks better with the variables not in the quotes.

> <%@page import="java.sql.*,javax.servlet.http.HttpServletRequest" %>
> <%!
> //Declare your variables;
> String DRIVER  = "org.gjt.mm.mysql.Driver";
> String CONNECT = "jdbc:mysql://127.0.0.1/userinfo";
> String QUERY   = "insert into info
> values('"+idnum+"','"+fname+"','"+lname+"','"+addr1+"','"+addr2+"'
> ,'"+city+"
> ','"+state+"','"+zip+"','"+phone1+"')";
> %>
> <%
> //some debug code to see what the values of these fields are... (not
> working)
> out.println(idnum);
> out.println(fname);
> out.println(lname);
> out.println(addr1);
> out.println(addr2);
> out.println(city);
> out.println(state);
> out.println(phone1);
> %>
> 
> <% //get information from another page, and, if there is no 
> information, set
> the values to NULL
> 
>  String idnum = request.getParameter("idnum");
>  String fname = request.getParameter("fname");
>  String lname = request.getParameter("lname");
>  String addr1 = request.getParameter("addr1");
>  String addr2 = request.getParameter("addr2");
>  String city = request.getParameter("city");
>  String state = request.getParameter("state");
>  String zip = request.getParameter("zip");
>  String phone1 = request.getParameter("phone1");
> 
> %>

Is there any particular reason you set the values of the variables
after you try to use them?

I think you'd be better off asking these questions in a java group,
as this is a pretty straightforward error.

Dave


my jsp updates with null values.

Posted by John Elia <je...@711.net>.
This code is inserting NULL values into a mysql database.  It is taking the
values from an HTML form, and should just insert the values.

Please Help.

<%@page import="java.sql.*,javax.servlet.http.HttpServletRequest" %>
<%!
//Declare your variables;
String DRIVER  = "org.gjt.mm.mysql.Driver";
String CONNECT = "jdbc:mysql://127.0.0.1/userinfo";
String QUERY   = "insert into info
values('"+idnum+"','"+fname+"','"+lname+"','"+addr1+"','"+addr2+"','"+city+"
','"+state+"','"+zip+"','"+phone1+"')";
%>
<%
//some debug code to see what the values of these fields are... (not
working)
out.println(idnum);
out.println(fname);
out.println(lname);
out.println(addr1);
out.println(addr2);
out.println(city);
out.println(state);
out.println(phone1);
%>

<% //get information from another page, and, if there is no information, set
the values to NULL

 String idnum = request.getParameter("idnum");
 String fname = request.getParameter("fname");
 String lname = request.getParameter("lname");
 String addr1 = request.getParameter("addr1");
 String addr2 = request.getParameter("addr2");
 String city = request.getParameter("city");
 String state = request.getParameter("state");
 String zip = request.getParameter("zip");
 String phone1 = request.getParameter("phone1");

%>


<% //Let's figure it out shall we?
Class.forName(DRIVER);
Connection con = DriverManager.getConnection(CONNECT);
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery(QUERY);
%>

<h4><br><b>WebDesk Development</b> USERINFO Database Accessed, INFO Table
Results returned.</h4><br>
<a href="JEInsert.jsp">Back to the Form</a>
<BR><BR><BR>