Link to home
Start Free TrialLog in
Avatar of APPIREDDY
APPIREDDY

asked on

Syntax error on tokens, delete these tokens

hi
i' m not understanding what's wrong with this code
error is
An error occurred at line: 15 in the jsp file: /shop/shop-products.jsp
Generated servlet error:
Syntax error on tokens, delete these tokens
help me
thanks


<%@ page language="java" contentType="text/html"  errorPage="errorpage.jsp" %>
<%@ page import = "shop.*" %>
<html>
<head><title>Welcome to the shop </title></head>
<body>
<table width="385" border="0" cellspacing="0">
<tr><td colspan="4">More books from Mike McGrath:</td></tr>
<tr><td colspan="4" align="right">
<a href="<%= response.encodeURL("shop-basket.jsp")%>">
<img src="images\viewbasket.gif"></a></td></tr>
<tr>
<td><b>Ref</b></td><td><b>Title</b></td>
<td><b>Price</b></td><td></td></tr>
 
<% Class.forName("com.mysql.jdbc.Driver"); 
   java.sql.Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","anu","kodanda");
   System.out.println("successful");
   java.sql.Statement stmt = connection.CreateStatement();
   java.sql.ResultSet RS = stmt.executeQuery("select * from items");
   
   int rowCounter=0;
   while(Rs.next())
   {
	   String item_id = Rs.getString("item_id");
	   String title = Rs.getString("title");
	   String description = Rs.getString("description");
	   String price = Rs.getString("price");
	   rowCounter++;
	   String bg =(rowCounter % 2 !=0)?"#C0C0C0":"FFFFFF";
>%
	   <tr bgcolor="<%= bg %>">
	   <td><%= item_id %></td>
	   <td><b><%= title %><b><br/><%=description %></td>
	   <td>£<%=price %></td>
	   <td>
	   <a href="<%= response.encodeUrl("shop-products.jsp?title="+title+"&item_id="+item_id+"&price="+price)%>">
	   <img src ="images\addtobasket.gif"><a></td>
	   </tr>
<%  }RS.close(); connection.close();%>
</table>
<jsp:useBean id="basket" class="shop.ShoppingBasket" scope="session"/>
<% String title = request.getParameter("title");
	   if(title!=null)
	   {
		   String item_id = request.getParameter("item_id");
		   double price = Double.parseDouble(request.getParameter("price"));
		   Product item = new Product(item_id,title,price);
		   basket.addProduct(item);
	   }
%>
</body></html>

Open in new window

Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

normally that error comes when  you have non closed comment sections..

i.e. start /* but not closing */..
Avatar of APPIREDDY
APPIREDDY

ASKER

i haven't used any comment
sometimes its little silly items that kill it..:)

          String bg =(rowCounter % 2 !=0)?"#C0C0C0":"FFFFFF";
>%


needs to be

          String bg =(rowCounter % 2 !=0)?"#C0C0C0":"FFFFFF";
%>

Notice the location of the % sign

Its the same comment I have added in your other question as well
Avatar of CEHJ
'RS' is getting its case mixed:

>>
java.sql.ResultSet RS = stmt.executeQuery("select * from items");
   
   int rowCounter=0;
   while(Rs.next())

>>
>    java.sql.ResultSet RS = stmt.executeQuery("select * from items");

change that to:

   java.sql.ResultSet Rs = stmt.executeQuery("select * from items");

> <%  }RS.close(); connection.close();%>

and that to:

<%  }Rs.close(); connection.close();%>


Though I'd suggest changing it from Rs to rs
ASKER CERTIFIED SOLUTION
Avatar of Kuldeepchaturvedi
Kuldeepchaturvedi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thank you very much kuladeep