views:

20

answers:

1

I think I'm doing something horrible wrong here.

I've never used NetBeans before, nor have I ever done anything with JavaServer before, though I've programmed in Java. In netBeans, in a web project, I created a package called DonationCalc, with a file DonationCalc.java, containing my bean. In a jsp file, I have the following:

<%@page import="DonationCalc.*" %> [...] <jsp:useBean id="Calc" class="DonationCalc" />

However, I'm getting "string:///DonationCalc_jsp.java:6: package DonationCalc does not exist"

I've been reading elsewhere about classes going under WEB-INF/Classes, but I have no such folder, and NetBeans insists any new packages be put under "Source Packages".

What do I need to add to help my .jsp file find the bean? A directory path of some sort? Or should I be putting things elsewhere to begin with?

ETA: Apparently the issue is that it was configured for glassfish instead of tomcat. Creating a new project under tomcat, however, has created such a clusterfuck of problems that I have sworn off all forms of java, including the island nation and all caffeinated beverages.

A: 

You don't need the @page import here since that only imports into the scriptlet scope, not into the taglib scope. You don't want to use scriptlets, so forget about it at all. In the jsp:useBean class you need to specify the full qualified classname, thus including the package name.

<jsp:useBean id="calc" class="com.example.DonationCalc" />

By the way:

I've been reading elsewhere about classes going under WEB-INF/Classes, but I have no such folder, and NetBeans insists any new packages be put under "Source Packages".

That's true. IDE's like Netbeans and Eclipse automatically builds and compiles the source files into the right locations. You don't need to worry about this. This is however mandatory to know when you want to understand how it works "under the hoods" and/or you want to (be able) to build using command console tools instead of an IDE.

BalusC
Thanks for the help, though like I said in my edit, it's now so utterly fucked up I despair of ever getting it to work. I suppose I'll make a separate thread for that though.
Bay
Breathe and take some coffee. Follow the right tutorials. For JSP/Servlet I strongly recommend the coreservlets.com tutorials. Here's a kickoff answer: http://stackoverflow.com/questions/1958808/java-web-development-what-skills-do-i-need/1958854#1958854 If you're completely new to Java as well, then I rather recommend to do learn its basics without an IDE first. Else you're trying to learn too much new things simultaneously .. Netbeans, Java SE, Java EE, JSP, Servlet, Tomcat, etc..etc.. That's quite stressing and frustating. Do it step by step. From little to big. Newborns don't drive cars.
BalusC