• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting-> 500 Internal Server Error  RSS feed

 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!
I am trying create module for online shopping!
But i am getting a same error in all of my jsp pages around the first statement of my code i.e.:
<%@ page language ="java" contentType="text/html"
import = "ShoppingBasket,Product" errorPage="errorpage.jsp" %>

And the error is:

Java Server Page Translation Error
Error during compilation :
C:\Java\jws\tmpdir\default\pagecompile\jsp\_shop_semptybasket.java:14: '.' expected
import ShoppingBasket;
^
C:\Java\jws\tmpdir\default\pagecompile\jsp\_shop_semptybasket.java:15: '.' expected
import Product;
^
C:\Java\jws\tmpdir\default\pagecompile\jsp\_shop_semptybasket.java:75: cannot resolve symbol
symbol : class ShoppingBasket
location: class pagecompile.jsp._shop_semptybasket
ShoppingBasket basket = null;
^
C:\Java\jws\tmpdir\default\pagecompile\jsp\_shop_semptybasket.java:78: cannot resolve symbol
symbol : class ShoppingBasket
location: class pagecompile.jsp._shop_semptybasket
basket= (ShoppingBasket)
^
C:\Java\jws\tmpdir\default\pagecompile\jsp\_shop_semptybasket.java:83: cannot resolve symbol
symbol : class ShoppingBasket
location: class pagecompile.jsp._shop_semptybasket
basket = (ShoppingBasket) Beans.instantiate(getClassLoader(), "ShoppingBasket");
^
5 errors

Please help me out since I write the above code line from one of the jsp books still i am getting error.
Thanks for the Help in Advance!
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your beans need to be packaged.
 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben!
According to your advice I packaged my bean in a package called shop,
But now i got a new error as:
Error during JSP page processing
javax.servlet.ServletException: Cannot create bean of class ShoppingBasket
at pagecompile.jsp._shop_sbasket._jspService(_shop_sbasket.java:86)

can you tell me what is going wrong.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you compiled them and put them in a directory named 'shop' under your classes directory under WEB-INF?
 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i compiled them stored in a webapps calss file. But it giving me the error can not create bean of that file is that mean there is an error in that class file code?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where exactly did you put the class files?
 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Path of my class file is :C:\Tomcat\webapps\classes\shop
well one more thing i want to tell you , while compiling my ShoppingBasket.java file I am getting warning as :

Note: ShoppingBasket.java uses uncheked or unsafe operations.
Note:Recompile with -Xlint:unchecked for details.

thats why now i think i must show you my code of ShoppingBasket as:

package shop;
import java.io.*;
import java.util.*;
public class ShoppingBasket
{
Vector products;
public ShoppingBasket() {products = new Vector(); }
public void addProduct(Product product) throws Exception
{
boolean flag = false;
for(Enumeration enu=getProducts();enu.hasMoreElements()
{
Product item=(Product)enu.nextElement();
if(item.getId().equals(product.id))
{
flag = true;
item.quantity++;
break;
}
}
if(!flag){products.addElement(product);}
}
public void deleteProduct(String str)
{
for(Enumeration enu =getProducts(); enu.hasMoreElements()
{
Product item = (Product)enu.nextElement();
if(item.getId().equals(str))
{
products.removeElement(item);
break;
}
}
}
public void emptyBasket() { products= new Vector(); }
public int getProductNumber() { return products.size(); }
public Enumeration getProducts(){ return products.elements(); }
public double getTotal()
{
Enumeration enu = getProducts();
double total;
Product item;
for(total=0.00;enu.hasMoreElements();total+=item.getTotal())
{
item = (Product) enu.nextElement();
}
return total;
}
}

I think due to the use of enumeration i am getting promblems
What is you opinion?
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your classes need to be under

TOMCAT_HOME/webapps/YOUR_CONTEXT_NAME/WEB-INF/classes/YOUR_PACKAGE_NAME/***
 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ben,
I did all that you told me to do.Now I am getting error as :
Cannot create bean of class ShoppingBasket
Well I dont know why I cant create a bean for this
 
rushikesh kale
Ranch Hand
Posts: 41
Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ben!


Well I am very very sorry for taking your precious time. Actully your second reply was more than enough to solve my problem. Actully i created the package but I forgot to change the ShoppingBasket name in my useBean tag to shop.ShoppingBasket i.e.
<jsp:useBean id="basket" class=[B]"shop.ShoppingBasket"[B] scope="session" />

Anyway thank you Very much for you grate grate help
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't be sorry. You have it working. Be happy.
When I don't have the time, I don't read the questions in the first place.

Glad it's fixed.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!