This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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�
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?
This is Java. You need to maintain the package hierarchy.
Joined: Feb 04, 2005
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?
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.