What do I need to do to use a bean in Netbeans 7 apart from defining it?
Hi!
I'm learning to use beans in JSP and from what I've gathered all I'm required to do is to create a class with appropriate constructor and getter-setter functions and specify it's name as value of the attribute "class" in the jsp:useBean action tag. But this is not working. I'm getting "cannot find symbol" errors while compiling.
Code :
/media/d/Portal/JAVA/WebKand/build/generated/src/org/apache/jsp/trial_jsp.java:124: cannot find symbol
symbol : class trialbean
location: class org.apache.jsp.trial_jsp
trialbean bn = null;
/media/d/Portal/JAVA/WebKand/build/generated/src/org/apache/jsp/trial_jsp.java:126: cannot find symbol
symbol : class trialbean
location: class org.apache.jsp.trial_jsp
bn = (trialbean) _jspx_page_context.getAttribute("bn", PageContext.REQUEST_SCOPE);
/media/d/Portal/JAVA/WebKand/build/generated/src/org/apache/jsp/trial_jsp.java:129: cannot find symbol
symbol : class trialbean
location: class org.apache.jsp.trial_jsp
bn = (trialbean) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "trialbean");
The .class file is in WEB-INF/classes.
Am I supposed to do something to enable the beans?
Re: What do I need to do to use a bean in Netbeans 7 apart from defining it?
You haven't posted your bean code, so does your bean follow the Javabeans Specification? I'd also recommend following the Java Naming Conventions - class names start with uppercase letters, and I'd put it in a package - I've had problems before with classes not being found when not in a package.
You might find the NetBeans JavaBeans Tutorial useful.
Re: What do I need to do to use a bean in Netbeans 7 apart from defining it?
Thanks a lot dlorde. Putting the bean in a package made it work. It's not necessary for class names to start with uppercase letters though.