Click to See Complete Forum and Search --> : SIMPLE: How do I use jbeans in jsp files???
yiannakop
September 30th, 2004, 02:44 PM
Hi everyone. I've been trying to use beans in my jsp files and always sth goes wrong. I am using Sun One Studio 4 IDE. Here's what excactly I do:
1. I've created a new web module
2. I've created file called dataBase.java (java bean) which does some simple sql queries.
3. I've used the above bean in a Jsp file.
When I execute the jsp file I get the following server error from apache:
java.lang.NoClassDefFoundError: IIHS_WEB/dataBase
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
...
...
I've read that the classes and beans have to be stored in the /class directory of the WEB_INF folder. I've done this, but still nothing...
Any ideas???
Please help!!! :sick:
Davey
September 30th, 2004, 03:24 PM
Does you class have a public no argument constructor, ie is it really a bean?
yiannakop
September 30th, 2004, 04:21 PM
Yes it does. Sun one studio automatically creates such a bean:
/*
* test.java
*
* Created on 30 Σεπτέμβριος 2004, 10:21 μμ
*/
package IIHS_WEB;
import java.beans.*;
/**
*
* @author Theodore G
*/
public class test extends Object implements java.io.Serializable {
private static final String PROP_SAMPLE_PROPERTY = "SampleProperty";
private String sampleProperty;
private PropertyChangeSupport propertySupport;
/** Creates new test */
public test() {
propertySupport = new PropertyChangeSupport( this );
}
public String getSampleProperty() {
return sampleProperty;
}
public void setSampleProperty(String value) {
String oldValue = sampleProperty;
sampleProperty = value;
propertySupport.firePropertyChange(PROP_SAMPLE_PROPERTY, oldValue, sampleProperty);
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertySupport.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener) {
propertySupport.removePropertyChangeListener(listener);
}
}
Any ideas? It has to do with placing the .class in the correct directory. Any ideas??
Thanx a lot for helping me Davey.
Davey
October 1st, 2004, 02:37 AM
Have you put this class in as WEB-INF/classes/IIHS_WEB/test.class.
Note, it must go in a "classes" directory , not a "class" directory. Also, the class directory hierarchy is case sensitive.
yiannakop
October 2nd, 2004, 03:02 PM
Have you put this class in as WEB-INF/classes/IIHS_WEB/test.class.
Note, it must go in a "classes" directory , not a "class" directory. Also, the class directory hierarchy is case sensitive.
Ok I found it davey. I found a tutorial about jsp and specific about using sun one studio. Indeed the directory naming is case sensitive and (for some strange reason...) I had changed the Classes dir. to classes :mad: . Anyway, I've learnt that to use a class you must "include" it in a package which must also be placed in the /Classes directory. Anyway, even if I hadn't found it, your answer would be 100% helpful for me so thank you very much. :wave:
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.