• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can anybody correct the errors in this jsp program

 
shelly sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic