Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java:76: cannot resolve symbol - Global Variable

843835Jan 8 2003 — edited Jan 8 2003
Hi,

In my jsp app I'm having difficultie. The code below throws up an error :

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

An error occurred at line: 46 in the jsp file: /VATCheck.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Tomcat4.1\work\Standalone\localhost\_\VATCheck_jsp.java:76: cannot resolve symbol
symbol : variable $totalCost
location: class org.apache.jsp.VATCheck_jsp
out.print(($totalCost));
^
1 error

CODE
<%String $Country = request.getParameter("CountryList");
out.println($Country);%>

<%
String VATCountry ="United Kingdom";
out.println(VATCountry);

if ($Country.equals(VATCountry)) {
out.println("Working");
double doubleProdCost = Double.valueOf(ProdCost).doubleValue();;
double TotalCost = (doubleProdCost*1.175);
out.println(TotalCost);
String $totalCost = String.valueOf(TotalCost);
out.println($totalCost);
}
%>

<input type=hidden name="amount" value="<%=($totalCost)%>">
<input type=hidden name="country" value="<%=($Country)%>"></P>

I think the problem is that when I use the following:
<input type=hidden name="amount" value="<%=($totalCost)%>"> the error is thrown up as the variable $totalcost is defined within my IF statement. Therefore it is only applicable within the If statement. Basically I need this variable to be a global variable. I've read around, but I'm a little confused as my understanding is that I have to define $totalCost as a class varriable. But I'm not creating any classes?? So I'm confused as I don't know how to define the variable $totalCost, such that it can be used anywhere in my JSP.

When i write the code <input type=hidden name="country" value="<%=($Country)%>"> I have no errors. Can you please help.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2003
Added on Jan 8 2003
2 comments
281 views