Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have little problem with compilin

Status
Not open for further replies.

preethib

Programmer
Jul 20, 2000
39
IN
I have little problem with compiling this bean to work with JSP. I use tomcat, and have all the below files in the jsp directory(/tomcat/jakartha/webapps/root/jsp/)

I have a html file 'FruitOrder.html' that basically takes the input for no. of punds and using the 'confirm.jsp', compiles using Fruit.class to provide output. I have compiled the Fruit.java locally but fail to have the bean work with JSP and HTML file.

Any help is appreciated. Below are the Exception errors I get with the attached source files.

Thanks a lot, preethib@yahoo.com.

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


I get an Exception error everytime I call the 'confirm.jsp' file.
"""""""""""""""
Error: 500
Location: /JSP_WCC/Source%20Code%20Listings/Session%2012/confirm.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:60: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
Fruit orderedFruit = null;
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:63: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
orderedFruit= (Fruit)
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:68: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
orderedFruit = (Fruit) Beans.instantiate(this.getClass().getClassLoader(), "Fruit");
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:108: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
out.print(JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getFruitName())));
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:114: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
out.print(JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getColor())));
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:120: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
out.print(JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getPrice())));
^
C:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080%2FJSP_WCC\_0002fSource_00020Code_00020Listings_0002fSession_00020_00031_00032_0002fconfirm_0002ejspconfirm_jsp_0.java:126: Class Source_00020Code_00020Listings.Session_00020_00031_00032.Fruit not found.
out.print(JspRuntimeLibrary.toString((((Fruit)pageContext.findAttribute("orderedFruit")).getQuantityInPounds())));
^
7 errors

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)

"""""""""""""""



Below are the files I have:
FruitOrder.html
--------------------------
<HTML>
<body>
<h1>Fruit Order Form</h1>

Fruit: Mango<br>
Color: Orange<br>
Price Per Pound: $5.95 <br>
<form action=&quot;confirm.jsp&quot; method=&quot;post&quot;>
Number of pounds: <input type=&quot;text&quot; name=&quot;quantity&quot;><br>
<input type=&quot;submit&quot; value=&quot;Order Fruit&quot; >
</form>
</body>
</html>
--------------------------
confirm.jsp
----------------------------
<jsp:useBean id=&quot;orderedFruit&quot; class=&quot;Fruit&quot; />

<jsp:setProperty name=&quot;orderedFruit&quot; property=&quot;fruitName&quot; value=&quot;Mango&quot; />

<jsp:setProperty name=&quot;orderedFruit&quot; property=&quot;color&quot; value=&quot;Orange&quot; />

<jsp:setProperty name=&quot;orderedFruit&quot; property=&quot;price&quot; value=&quot;5.95&quot; />

<jsp:setProperty name=&quot;orderedFruit&quot; property=&quot;quantityInPounds&quot; param=&quot;quantity&quot; />

<HTML>
<body>
<h1>Your Fruit Order</h1>
<br><br>
Fruit: <jsp:getProperty name=&quot;orderedFruit&quot; property=&quot;fruitName&quot;/><br>
Color: <jsp:getProperty name=&quot;orderedFruit&quot; property=&quot;color&quot; /><br>
Price: $<jsp:getProperty name=&quot;orderedFruit&quot; property=&quot;price&quot; /><br>
Quantity: <jsp:getProperty name=&quot;orderedFruit&quot; property=&quot;quantityInPounds&quot; /><br>
Total:&nbsp;$<%=orderedFruit.getPrice()*orderedFruit.getQuantityInPounds() %>
<p></p>
<a href=&quot;FruitOrder.html&quot;>Return to order form to adjust quantity</a>
</body>
</html>

--------------------------
Fruit.java
--------------------------
public class Fruit {
private String fruitName;
private int quantity;
private String color;
private boolean isCitrus;
private float price;

public String getFruitName(){
return this.fruitName;
}

public void setFruitName(String name){
this.fruitName=name;
}

public int getQuantityInPounds(){
return this.quantity;
}

public void setQuantityInPounds(int quantity){
this.quantity=quantity;
}

public String getColor(){
return this.color;
}

public void setColor(String color){
this.color=color;
}

public float getPrice(){
return this.price;
}

public void setPrice(float price){
this.price=price;
}

public boolean isCitrus(){
return this.isCitrus;
}

public void setCitrus(boolean isCitrus){
this.isCitrus=isCitrus;
}
}
--------------------------
 
Sounds like you need to import the package that Fruit is found in. Example (if Fruit is in the com.produce package):
Code:
<%@ page import=&quot;com.package.Fruit&quot; %>
Wushutwist
 
Hi Wushutwist,

I have a new error, in the confirm.jsp File I inserted
==><%@ page import=&quot;packages.Fruit&quot; %>

I have the Fruit.class and Fruit.java in the packages folder.

I get the following error:

org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080\_0002fhtml_0002fconfirm_0002ejspconfirm_jsp_1.java:15: Class packages.Fruit not found in import.
import packages.Fruit;
^
1 error

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)



Where am I wrong??

Thanks.

Preethi
 
Before I spend a long time explaining things (perhaps unnecessarily), let me ask you a question. Do you understand how the package structure works in Java and how it relates to the directory structure of .class files? Wushutwist
 
I have my localhost root set
->localhost:8080
pointing to
C:\tomcat\jakartha.3.2.2\webapps\root\
under which I have
\css
\gif
\html
\jsp
\packages
\servelets

So if I do a I see all the above folders.

In the \html, I have FruitOrder.html, where the form action points to &quot;..\jsp\confirm.jsp&quot;

<HTML>
<body>
<h1>Fruit Order Form</h1>

Fruit: Mango<br>
Color: Orange<br>
Price Per Pound: $5.95 <br>
<form action=&quot;../jsp/confirm.jsp&quot; method=&quot;post&quot;>
Number of pounds: <input type=&quot;text&quot; name=&quot;quantity&quot;><br>
<input type=&quot;submit&quot; value=&quot;Order Fruit&quot; >
</form>
</body>
</html>

packages directory has Fruit.class

The error I have on submission from the FruitOrder.html is:

Error: 500
Location: /jsp/confirm.jsp
Internal Servlet Error:

org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\jakarta-tomcat-3.2.2\work\localhost_8080\_0002fjsp_0002fconfirm_0002ejspconfirm_jsp_0.java:15: Class packages.Fruit not found in import.
import packages.Fruit;
^
1 error

at org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:612)
at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146)
at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:542)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:258)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:268)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:429)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:500)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
at org.apache.tomcat.core.Handler.service(Handler.java:287)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)

---

Does this make sense?, I could be wrong..but I have appreciate if you could point me where I am....

Thanks,Preethi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top