/    Sign up×
Community /Pin to ProfileBookmark

Unable to compile class for JSP

I am a beginner learning JSP by myself.I am encountering an error when i am trying to implement JavaBean with JSP.
[B]
This is the error message[/B]

An error occurred at line: 15 in the jsp file: /confirm.jsp
Generated servlet error:
C:Documents and Settingsstudent.netbeans4.1jakarta-tomcat-5.5.7_baseworkCatalinalocalhostFirst_Pageorgapachejspconfirm_jsp.java:51: cannot resolve symbol
symbol : class Fruit
location: class org.apache.jsp.confirm_jsp
Fruit order = null;

I have 3 different programs
[B]
Fruit.Java( which is the bean)[/B]

public class Fruit {

public String fname;
public int quantity;
public String color;
public float price;
private String sampleProperty;

public String getfname() {
return this.fname;
}

public void setfname(String name) {
this.fname = name;
}

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

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

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

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

}
[B]
FruitOrder.html[/B]

<html>
<head>
<title>Fruit Order</title>
</head>
<body>
Fruit : Mango<br>
Price per Pound : $5<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>

and [B]confirm.jsp[/B]

<jsp:useBean id =”order” class = “Fruit” />
<jsp:setProperty name =”order” property=”fname” value=”Mango” />
<jsp:setProperty name =”order” property=”quantity” param=”quantity” />

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title> Fruit order</title>
</head>

<h1>JSP Page</h1>

<body>
Fruit : <jsp:getProperty name=”order” property=”fname” />
Quantity : <jsp:getProperty name=”order” property=”quantity” />
Cost : <%=order.getPrice() * order.getQty() %>
</body>

</html>

I know its a very basic program and I am missing one of the silly points..But i have checked and rechecked it ..everything seems to be perfect..I am reakky getting frustrated ..please help before i quit learning ?

Thanks

to post a comment
Java

8 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliMar 23.2006 — this here is your problem

[b]

...confirm_jsp.java:51: cannot resolve symbol

symbol : class Fruit

[/b]


This means that the reference to this object(fruit) is not valid. what you will need to do is make sure that Frut is accessible in the jsp, try to import it(using the import statement at the top of the page.
Copy linkTweet thisAlerts:
@desigabruauthorMar 23.2006 — Thanks Khalid...will try and let you kno if it works ?

desi
Copy linkTweet thisAlerts:
@Khalid_AliMar 23.2006 — if u still have problems, [url=http://www.webdeveloper.com/forum/showthread.php?p=245219#post245219]read this thread[/url]. The first part is the tutorial,towards the end of first thread I have a link for how to deploy servlets. Read that it explains how to setup the webapplications directories and such.This will take care of problems that u are having
Copy linkTweet thisAlerts:
@desigabruauthorMar 24.2006 — I did try and import the Fruit Class by using

<%@page import ="Fruit"%> ..but in vain..

In regards to your setup tutorial..I am using the Netbean IDE which I guess takes care of every thing.These three (.java,.html and .jsp) are under a web project called First_Page.

I dont kno what should i do?...Actually this is one of the examples from JSP weekend crash course book.I have done exactly as stated in the book.

Do u really think that its the setup which is creating the problem???
Copy linkTweet thisAlerts:
@Khalid_AliMar 24.2006 — yes, do one thing....zip all of ur project files and email me....
Copy linkTweet thisAlerts:
@jetbrainsMar 25.2006 — Add tools.jar into lib dircetory
Copy linkTweet thisAlerts:
@desigabruauthorMar 25.2006 — I shall mail you the zip file on monday

thanks
Copy linkTweet thisAlerts:
@desigabruauthorMar 27.2006 — Hi Khalid

As instructed by you i am hereby attaching the three files...(I hope you know that i am usiong Netbeans IDE 4.1)

Thanks a lot

desi

[upl-file uuid=34cb0979-0c92-4a37-a72e-ecf6036fd96a size=2kB]fruit.zip[/upl-file]
×

Success!

Help @desigabru spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...