• Post Reply Bookmark Topic Watch Topic
  • New Topic

javabeans problem.

 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well i have bean in the following package.
package pro;
public class FirstBean
{
int val;
public void set(int i){
this.val=i;
}
public int get(){
return val;
}
}
I am using tomcat4
jsp files i have putten in
c:\tomcat4\webapps\examples\jspfiles
wrox have specified put in classes folder or in the web-inf\lib folder.
I have not lib folder in tomcat in web-inf and it does not work in classes folder.
Please tell where to put package and from where to compile and run it.
 
hkg
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add the following thing to your code
1) import java.beans.*; on top
2) Put your class in /web-inf/classes directory
3) set classpath to classes directory in autoexec.bat file
 
Tim Holloway
Bartender
Posts: 18417
60
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you only need to import java.beans.* if you're referencing components. Any Java class is a minimal bean if it has set/get methods and a no-argument constructor.
Also, you don't need to add the CLASSPATH. Tomcat automatically adds the WEB-INF/classes folder and contents of the WEB-INF/lib directory when it starts up the web app. Note that because you're using a package, the ".class" file should WEB-INF/classes/pro/FirstBean.class - including correct upper/lower case spellings.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!