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="confirm.jsp" method="post">
Number of pounds: <input type="text" name="quantity"><br>
<input type="submit" value="Order Fruit" >
</form>
</body>
</html>
--------------------------
confirm.jsp
----------------------------
<jsp:useBean id="orderedFruit" class="Fruit" />
<jsp:setProperty name="orderedFruit" property="fruitName" value="Mango" />
<jsp:setProperty name="orderedFruit" property="color" value="Orange" />
<jsp:setProperty name="orderedFruit" property="price" value="5.95" />
<jsp:setProperty name="orderedFruit" property="quantityInPounds" param="quantity" />
<HTML>
<body>
<h1>Your Fruit Order</h1>
<br><br>
Fruit: <jsp:getProperty name="orderedFruit" property="fruitName"/><br>
Color: <jsp:getProperty name="orderedFruit" property="color" /><br>
Price: $<jsp:getProperty name="orderedFruit" property="price" /><br>
Quantity: <jsp:getProperty name="orderedFruit" property="quantityInPounds" /><br>
Total: $<%=orderedFruit.getPrice()*orderedFruit.getQuantityInPounds() %>
<p></p>
<a href="FruitOrder.html">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;
}
}
--------------------------
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="confirm.jsp" method="post">
Number of pounds: <input type="text" name="quantity"><br>
<input type="submit" value="Order Fruit" >
</form>
</body>
</html>
--------------------------
confirm.jsp
----------------------------
<jsp:useBean id="orderedFruit" class="Fruit" />
<jsp:setProperty name="orderedFruit" property="fruitName" value="Mango" />
<jsp:setProperty name="orderedFruit" property="color" value="Orange" />
<jsp:setProperty name="orderedFruit" property="price" value="5.95" />
<jsp:setProperty name="orderedFruit" property="quantityInPounds" param="quantity" />
<HTML>
<body>
<h1>Your Fruit Order</h1>
<br><br>
Fruit: <jsp:getProperty name="orderedFruit" property="fruitName"/><br>
Color: <jsp:getProperty name="orderedFruit" property="color" /><br>
Price: $<jsp:getProperty name="orderedFruit" property="price" /><br>
Quantity: <jsp:getProperty name="orderedFruit" property="quantityInPounds" /><br>
Total: $<%=orderedFruit.getPrice()*orderedFruit.getQuantityInPounds() %>
<p></p>
<a href="FruitOrder.html">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;
}
}
--------------------------