aspose file tools*
The moose likes Servlets and the fly likes can anybody correct the errors in this jsp program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "can anybody correct the errors in this jsp program" Watch "can anybody correct the errors in this jsp program" New topic
Author

can anybody correct the errors in this jsp program

shelly sharma
Ranch Hand

Joined: Sep 17, 2003
Posts: 32
here is my program. can anybody correct the errors in this program:
<HTML><HEAD><TITLE></TITLE></HEAD><BODY>
<%! string itemName=["Item 1", "Item 2", "Item 3"];
double itemCost=[123.00, 234.50, 345.50];
double totalCost= 0.0;
%>
<UL>
<% for(int j=0; j<itemName.length; j++){
%> <LI> Item=<%=itemName[j] %>, $<%=itemCost[j]%>
<% totalCost= totalCost +itemCost[j];
}
%>
</UL>
Total=<% totalCost %>
</BODY>
</HTML>
The errors are as follows:
org.apache.jasper.JasperException: Unable to compile class for JSPC:\tomcat\work\localhost_8080%2Fexamples\_0002fiteration_0002ejspiteration_jsp_0.java:18: Missing term.
string itemName=["Item 1", "Item 2", "Item 3"];
^
C:\tomcat\work\localhost_8080%2Fexamples\_0002fiteration_0002ejspiteration_jsp_0.java:18: ']' expected.
string itemName=["Item 1", "Item 2", "Item 3"];
^
C:\tomcat\work\localhost_8080%2Fexamples\_0002fiteration_0002ejspiteration_jsp_0.java:19: Missing term.
double itemCost=[123.00, 234.50, 345.50];
^
C:\tomcat\work\localhost_8080%2Fexamples\_0002fiteration_0002ejspiteration_jsp_0.java:19: ']' expected.
double itemCost=[123.00, 234.50, 345.50];
^
4 errors
akkeri akkeri
Greenhorn

Joined: Oct 06, 2003
Posts: 1
this is the answear
<HTML><HEAD><TITLE></TITLE></HEAD><BODY>
<%String[] itemName={"Item 1", "Item 2", "Item 3"};
double itemCost[]={123.00, 234.50, 345.50};
double totalCost= 0.0;
%>
<UL>
<% for(int j=0; j<itemName.length; j++){
%> <LI> Item=<%=itemName[j] %>, $<%=itemCost[j]%>
<% totalCost= totalCost +itemCost[j];
}
%>
</UL>
Total=<%=totalCost%>
</BODY>
</HTML>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can anybody correct the errors in this jsp program