• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple prob

 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using Blazix.. in classes the bean files r placed..
The thing is i've made two classes User and Login.. i place the classes inside classes\jsp folder.. so i write at top of both of the files as
package jsp;
the prob is:
in Login class i want to make an object of User class as
User user=new User();
when compiling it says package jsp not found..
pls tell me do i need to configue my server for this..
u can say from Tomcat and JavaWebServer point of view as well..
Thanks in advn..
Pranit..
 
George Joseph
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Pranit,
In case of TOMCAT You should place you class file in the WEB-INF/classes folder of your current context.
That is if your jsp page is in folder say
tomcat/webapps/example/*.jsp
Then your class file must be in the folder
tomcat/webapps/example/WEB-INF/classes/jsp/*.class

In your jsp page you must use the statement
<%@ page import="jsp.*"%>
<%
jsp.User user=new jsp.User();
%>
Hope this will solve your problem

George

Originally posted by Pranit Saha:
I'm using Blazix.. in classes the bean files r placed..
The thing is i've made two classes User and Login.. i place the classes inside classes\jsp folder.. so i write at top of both of the files as
package jsp;
the prob is:
in Login class i want to make an object of User class as
User user=new User();
when compiling it says package jsp not found..
pls tell me do i need to configue my server for this..
u can say from Tomcat and JavaWebServer point of view as well..
Thanks in advn..
Pranit..

 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi George,
Thanks for ur reply.. but my prob hasn't been solved yet.. i'm attaching my two java files.. Item.java and Catalog.java.. i've placed it in WEB-INF\classes.. after compilation of Item.java, Catalog.java gives 14 errors.. as class Jsp.Item not found.. Jsp is a folder i made in WEB-INF\classes\Jsp..
Item.java
==========
package Jsp;
public class Item
{
private String itemId;
private float price;
private String description;
private boolean available;
private int quantity_in_stock;
public Item(String itemId,String description, float price, boolean available,int quantity_in_stock)
{
this.itemId = itemId;
this.description = description;
this.price = price;
this.available = available;
this.quantity_in_stock = quantity_in_stock;
}
public String getItemId()
{
return itemId;
}
public void setItemId(String aItemId)
{
itemId = aItemId;
}
public float getPrice()
{
return price;
}
public String getDescription()
{
return description;
}
public boolean getAvailable()
{
return available;
}
public void setAvailable(boolean aAvailable)
{
available = aAvailable;
}
public int getQuantity_in_stock()
{
return quantity_in_stock;
}
public void setQuantity_in_stock(int aQuantity_in_stock)
{
quantity_in_stock = aQuantity_in_stock;
}
}


Catalog.java
=============
package Jsp;
import java.util.Vector;
public class Catalog
{
private Vector items = new Vector();

synchronized public Vector getItems(String itemId)
{
return items;
}
synchronized public Item getItem(String itemId)
{
int index = Integer.parseInt(itemId);
return (Item)items.elementAt(index);
}
synchronized public void setItem(Item item, String itemId)
{
int index= Integer.parseInt(itemId);
items.set(index,item);
}
public Catalog()
{
/*
* This could be the place for some JDBC code to connect and retrieve
* inventory information, create Item objects and store them here
*/
items.addElement(new Jsp.Item("0","ToothBrush",(float)10,true,100));
items.addElement(new Jsp.Item("1","Comb",(float)1, true,100));
items.addElement(new Item("2","Razor",(float)13,true,1000));
items.addElement(new Item("3","After Shave",(float)10,true,900));
items.addElement(new Item("4","Cologne",(float)25,true,133));
items.addElement(new Item("5","Shaving Cream",(float)12,true,353));
items.addElement(new Item("6","Razor Blades",(float)9,true,333));
items.addElement(new Item("7","Pen Stand",(float)0.99,true,222));
items.addElement(new Item("8","Duke benbie",(float)19,true,343));
items.addElement(new Item("9","Elec Razor",(float)100,true,884));
}
}
Pranit..
 
George Joseph
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pranit,
Please check the the case of all the package and class name
Note :
package Jsp;
and
pacakage jsp;
are different
similarly in the jsp file import statement must be
<%@ page import="Jsp.Item,Jsp.Catalog"%>
After checking/ compiling all the classes restart the tomcat.
If still error comes post the error message of Tomcat window.

George


Originally posted by Pranit Saha:
Hi George,
Thanks for ur reply.. but my prob hasn't been solved yet.. i'm attaching my two java files.. Item.java and Catalog.java.. i've placed it in WEB-INF\classes.. after compilation of Item.java, Catalog.java gives 14 errors.. as class Jsp.Item not found.. Jsp is a folder i made in WEB-INF\classes\Jsp..
Item.java
==========
package Jsp;
public class Item
{
private String itemId;
private float price;
private String description;
private boolean available;
private int quantity_in_stock;
public Item(String itemId,String description, float price, boolean available,int quantity_in_stock)
{
this.itemId = itemId;
this.description = description;
this.price = price;
this.available = available;
this.quantity_in_stock = quantity_in_stock;
}
public String getItemId()
{
return itemId;
}
public void setItemId(String aItemId)
{
itemId = aItemId;
}
public float getPrice()
{
return price;
}
public String getDescription()
{
return description;
}
public boolean getAvailable()
{
return available;
}
public void setAvailable(boolean aAvailable)
{
available = aAvailable;
}
public int getQuantity_in_stock()
{
return quantity_in_stock;
}
public void setQuantity_in_stock(int aQuantity_in_stock)
{
quantity_in_stock = aQuantity_in_stock;
}
}


Catalog.java
=============
package Jsp;
import java.util.Vector;
public class Catalog
{
private Vector items = new Vector();

synchronized public Vector getItems(String itemId)
{
return items;
}
synchronized public Item getItem(String itemId)
{
int index = Integer.parseInt(itemId);
return (Item)items.elementAt(index);
}
synchronized public void setItem(Item item, String itemId)
{
int index= Integer.parseInt(itemId);
items.set(index,item);
}
public Catalog()
{
/*
* This could be the place for some JDBC code to connect and retrieve
* inventory information, create Item objects and store them here
*/
items.addElement(new Jsp.Item("0","ToothBrush",(float)10,true,100));
items.addElement(new Jsp.Item("1","Comb",(float)1, true,100));
items.addElement(new Item("2","Razor",(float)13,true,1000));
items.addElement(new Item("3","After Shave",(float)10,true,900));
items.addElement(new Item("4","Cologne",(float)25,true,133));
items.addElement(new Item("5","Shaving Cream",(float)12,true,353));
items.addElement(new Item("6","Razor Blades",(float)9,true,333));
items.addElement(new Item("7","Pen Stand",(float)0.99,true,222));
items.addElement(new Item("8","Duke benbie",(float)19,true,343));
items.addElement(new Item("9","Elec Razor",(float)100,true,884));
}
}
Pranit..

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!