• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot Resolve Symbol & my file uses or overrides deprecated API errors

Donna Harrington
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everybody,
I hope somebody can help me.I am trying to create an online shopping cart that uses sessions. So i have a servlet side and a class Product and the client side 'ShopCart'. I have 2 errors..one is in the ShopCart.jsp file where it cannot resolve symbol 'class Product' and the other error is ShopCart.jsp uses or overrides deprecated API.
Here is ShopCart which is -->

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import = "java.sql.*"%>
<%@page import = "java.io.*"%>
<%@page import = "java.util.Properties"%>
<%@page import = "java.io.InputStream"%>
<%@page session = "true"%>
<%@page import = "java.util.*"%>

Vector buylist = (Vector) session.getValue("shopping.shoppingcart");
if (buylist != null && (buylist.size() > 0)) {
<table border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
<td><b>Product Name</b></td>
for (int index=0; index < buylist.size();index++) {
Product anOrder = (Product) buylist.elementAt(index);
<td><b><%= anOrder.getProductId() %></b></td>
<td><b><%= anOrder.getPName() %></b></td>
<td><b><%= anOrder.getPrice() %></b></td>
<td><b><%= anOrder.getQuantity() %></b></td>
<form name="deleteForm"
action="C:\Documents and Settings\HarringtonD\.netbeans\3.6\sampledir\WEB-INF\classes\com\mycompany\ShoppingServlet"
<input type="submit" value="Delete">
<input type="hidden" name= "delindex" value='<%= index %>'>
<input type="hidden" name="action" value="DELETE">
<% } %>
<form name="checkoutForm"
action="C:\Documents and Settings\HarringtonD\.netbeans\3.6\sampledir\WEB-INF\classes\com\mycompany\ShoppingServlet"
<input type="hidden" name="action" value="CHECKOUT">
<input type="submit" name="Checkout" value="Checkout">
<% } %>

Here is my class Product -->

package shopping.Product;
public class Product {
String productId;
String PName;
float price;
int quantity;

/** Creates a new instance of Product */
public Product() {


public void setProductId(String title){
public String getProductId(){
return ProductId;
public String getPName(){
return PName;
public void setPrice(float p){
public void setQuantity(){
return quantity;

And Finally Here is my Servlet -->

package shopping.Product;

import java.io.*;
import java.net.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

* @author HarringtonD
* @version
public class ShoppingServlet extends HttpServlet {
public void init(ServletConfig conf) throws ServletException {
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
HttpSession session = req.getSession(false);
if (session == null) {
Vector buylist=
String action = req.getParameter("action");
if (!action.equals("CHECKOUT")) {
if (action.equals("DELETE")) {
String del = req.getParameter("delindex");
int d = (new Integer(del)).intValue();
} else if (action.equals("ADD")) {
//any previous buys of same cd?
boolean match=false;
Product aProduct = getProduct(req);
if (buylist==null) {
//add first cd to the cart
buylist = new Vector(); //first order
} else { // not first buy
for (int i=0; i< buylist.size(); i++) {
Product prod = (Product) buylist.elementAt(i);
if (prod.getProductId().equals(aProduct.getProductId())) {
match = true;
} //end of if name matches
} // end of for
if (!match)
session.putValue("shopping.shoppingcart", buylist);
String url="http://localhost:8084/sampledir/ShopCart.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);
} else if (action.equals("CHECKOUT")) {
float total =0;
for (int i=0; i< buylist.size();i++) {
Product anOrder = (Product) buylist.elementAt(i);
float price= anOrder.getPrice();
int qty = anOrder.getQuantity();
total += (price * qty);
total += 0.005;
String amount = new Float(total).toString();
int n = amount.indexOf('.');
amount = amount.substring(0,n+3);
String url="http://localhost:8084/sampledir/checkout.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
private Product getProduct(HttpServletRequest req) {
String myProduct = req.getParameter("Product");
String qty = req.getParameter("qty");
StringTokenizer t = new StringTokenizer(myProduct,"|");
String productId= t.nextToken();
String PName = t.nextToken();
String price = t.nextToken();
price = price.replace('$',' ').trim();
Product prod = new Product();
prod.setPrice((new Float(price)).floatValue());
prod.setQuantity((new Integer(qty)).intValue());
return prod;

I hope somebody can help me., I cant see these erros..sorry about all the code. thanx.
Mike Nightsky
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the jsp the package import for the java and the servlet is missing.
<%@page import ="shopping.Product.*"%>
this should solve your first problem.
the second one is just a warning, that means some parts of your code that you are using is marked as deprecated.
try to look in your log-files to see if you could find a clue.
If not try to compile the classes with -deprecation after javac, or if you use a IDE check if you could add this option in the settings.

Mike :roll:
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!