aspose file tools*
The moose likes JSP and the fly likes Package does not exist�.javaBeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Package does not exist�.javaBeans" Watch "Package does not exist�.javaBeans" New topic
Author

Package does not exist�.javaBeans

Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
I am trying to use javabeans. Here is what I am doing. I have a class called �Constants.java� that is in a package call db. The purpose of the class is to hold my sql strings and reset them if it is production or development (the reason being is that development does not match production exactly)
In my first jsp, �index.jsp�, I included this line�


My thinking is that I need to be able to use the getter methods of Constant anywhere in the application.

I get three errors but the first one is
Package db does not exist
db.Constant = null;
^
In my IDE I set it up the structure like this�

Application
|
|-db
| |-Constant.java
|-JRE�s
|-WEB-INF
|-index.jsp
|-blah.jsp, etc

What am I doing wrong and why?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

Did you compile the bean? Did you place the resulting class file in the WEB-INF/classes hierarchy?
[ February 07, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Obviously my reference seems to be lacking some details as they did not include the instructions you just gave. I thought these things were complied by Tomcat on startup.

No, I did not pre-compile and place in a WEB-INF/classes directory. I have since created a �classes� directory and, after deploy the war file, I copied the �Constant.class� file from it�s location at webapps/applName/db to webapps/applName/WEB-INF/classes but I still get the same problem.

Clearly I am doing something wrong. Can you give me a bit more help please?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

Make it

webapps/applName/WEB-INF/classes/db


This is Java. You need to maintain the package hierarchy.
Pat Peg
Ranch Hand

Joined: Feb 04, 2005
Posts: 194
Ah...thanks sheriffAh...thanks sheriff. I didn�t have the package moved over. It seems to work now. I have another question. I am using eclipse and the structure I presented with the post.
1)Should I just move all packages to the WEB-INF folder?
2)Is there a setting I am missing when I make a WAR file?
3)Web.xml? will this prevent me from having to do number 1?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61606
    
  67

You should ask Eclipse setup questions in the IDEs forum, but I would not mix my Java source files in with the web app. Keep them in a separate location and only move the class files to the appropriate location.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Package does not exist�.javaBeans