Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Syntax error on tokens, delete these tokens

Posted on 2009-02-12
7
Medium Priority
?
5,546 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:APPIREDDY
7 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 23625018
normally that error comes when  you have non closed comment sections..

i.e. start /* but not closing */..
0
 

Author Comment

by:APPIREDDY
ID: 23625099
i haven't used any comment
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 23625575
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 86

Expert Comment

by:CEHJ
ID: 23625973
'RS' is getting its case mixed:

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

>>
0
 
LVL 92

Expert Comment

by:objects
ID: 23626740
>    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
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 2000 total points
ID: 23626796
apart from already mentioned items..

following will also give you compile errors

java.sql.Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","anu","kodanda");
   System.out.println("successful");
   java.sql.Statement stmt = connection.CreateStatement();

needs to be

java.sql.Connection connection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","anu","kodanda");
   System.out.println("successful");
   java.sql.Statement stmt = connection.createStatement();

Notice that I have qualified the drivermanager ( since you are not importing the package)
and CreateStatement is createStatement.
0
 

Author Comment

by:APPIREDDY
ID: 23627520
thank you very much kuladeep
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question