Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Package does not exist error

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi guys, am new to jsp so hope you can help me out.
Am trying to link up a simple database with a bean, but am not too sure how to do this.

I keep getting the following error:

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 2 in the jsp file: /jsp/email_address.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\cartapp\jsp\email_address_jsp.java:7: package cust does not exist
import cust.*;
^
C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\cartapp\jsp\email_address_jsp.java:43: package cust does not exist
cust.Customer newcust = null;
^



An error occurred at line: 2 in the jsp file: /jsp/email_address.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\cartapp\jsp\email_address_jsp.java:45: package cust does not exist
newcust = (cust.Customer) pageContext.getAttribute("newcust", PageContext.REQUEST_SCOPE);
^



An error occurred at line: 2 in the jsp file: /jsp/email_address.jsp

Generated servlet error:
C:\jakarta-tomcat-4.1.30\work\Standalone\localhost\cartapp\jsp\email_address_jsp.java:48: package cust does not exist
newcust = (cust.Customer) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "cust.Customer");
^
4 errors


at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)


I've placed email_address.jsp in C:\CARTAPP\jsp and the customer.class file in C:\CARTAPP\jsp\WEB-INF\classes\cust. When i run email_address.jsp on the server i get the above error.

Heres the email_address.jsp file for your convenience:
------------------------------------------------------------------
<%@page import="cust.*"%>

<jsp:useBean id = "newcust" class="cust.Customer" scope ="request"/>
<jsp:setProperty name = "newcust" property = "*"/>

<%newcust.createCustomer();%>

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Email Address</title>
</head>

<body>

<form method = post action = "email_address.jsp">

<table border="0" width="61%">
<tr>
<td width="20%">Email Address</td>
<td width="80%"><input type="text" name="email_address" size="20"></td>
</tr>
<tr>
<td width="20%">Password</td>
<td width="80%"><input type="text" name="password" size="20"></td>
</tr>
<tr>
<td width="20%"></td>
<td width="80%"><input type="reset" value="Reset" name="B2"><input type="submit" value="Submit" name="B1"></td>
</tr>
</table>
<p><br>
</p>

</body>

</html>

--------------------------------------------------------------------

And heres the customer.java file:

import java.sql.*;

public class Customer{
private String email_address;
private String password;

public String getCustomerEmail(){
return email_address;
}

public void setCustomerEmail(String e){

email_address = e;
}


public String getCustomerPass(){
return password;
}

public void setCustomerPass(String p){

password = p;
}

public void createCustomer(){

Connection conn = null;
Statement st = null;
PreparedStatement pst;
//Resultset rs = null;

try{
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
conn=
DriverManager.getConnection("jdbc:mysql://localhost/cartapp");

st = conn.createStatement();
pst=conn.prepareStatement("insert into customer (Customer_ID,Email_Address,Password) "+" values (?,?,?)");
pst.setString(1,"NULL");
pst.setString(2,getCustomerEmail());
pst.setString(3,getCustomerPass());
pst.executeUpdate();
pst.close();
}

catch (Exception ex){
ex.printStackTrace();}

}

}
---------------------------------------------------------------------

Your help is very much appreciated,
Jitesh
[ September 09, 2004: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I don't see "package cust;" at the top of the Customer.java file. You need to add it and recompile for the Customer.class to be in package cust.

Jules
 
Jitesh Ranavaya
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hey, I just tried doing that, but it still comes out with the same error.
Have I got the files in the right places?
As far as I know, all class files go in the "WEB-INF" folder, and the jsp file has to be outside it.
E.g.
"C:\CARTAPP\jsp" is where email_address.jsp is.
"C:\CARTAPP\jsp\WEB-INF\classes\cust" is where the Customer.class file is.
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
It all looks fine to me. If you recompiled and replaced the old Customer.class in the cust subdirectory then maybe you need to restart the app server or clear out the work area.

Jules
 
Jitesh Ranavaya
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for trying to help mate, but am still having the same problem
 
JulianInactive KennedyInactive
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Maybe it's the fact that you're importing cust.* in your JSP and then trying to use a bean called cust.Customer. I've seen instances where doing both together doesn't work well.

Jules
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
... did you get the example to work? I'm having almost exactly same problem. Would love to find out what happened.
T
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
tomasz brymora,

This is a pretty old thread and neither of it's participants have posted in a while.
Why don't you start a new one with a description of your problem and the relevent section of the stack trace?

-Ben
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yes, most people will ignore "zombies" (old threads resurrected).

To make sure that conversations don't occur in two places I'm going to close this thread so tomasz can open a new one in which he can post the details of the problem that he is having.
    Bookmark Topic Watch Topic
  • New Topic