aspose file tools*
The moose likes Servlets and the fly likes JSP's and class files..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP Watch "JSP New topic
Author

JSP's and class files.....

Stone Golem
Greenhorn

Joined: Oct 27, 2001
Posts: 8
Hi all... I've written and compiled java code and it's in the format of a .class file, but it doesn't really meet the standards set out for beans. I was wondering how I can have my jsp's use my getters and setters within my class files. I was wondering also if I need to put the class files in a certain directory, so that the jsp's can see the class files. (I'm using Tomcat!) I was playing a bit with the useBean tag, but I guess I'm a little bit of a greenhorn, as I have hit a roadblock.
Any help would be greatly appreciated.
Thanks,
Stone
Simon Brown
sharp shooter, and author
Ranch Hand

Joined: May 10, 2000
Posts: 1913
    
    6
Hi Stone,
Answering the second bit first ... there are a number of places in which the class files can be placed. The easiest place to put them while you are learning about JSPs is in a directory called "classes" underneath the WEB-INF directory of your web application.
The TOMCAT_HOME\webapps\examples directory is an example web application. A "web application" (or webapp) is essentially just a specific directory structure in which to place all of the resources that make up your web application. The JSP files generally sit at the top of the webapp (for example, directly under the examples directory), while the classes can sit under the WEB-INF\classes directory.
If you place your class files under the WEB-INF\classes directory, remember to create the appropriate directory structure to meet your package structure.
Once the JSP can see the classes, you just need to have the appropriate get and set methods for each property in your class. For example, if you have a property called name, you should gave methods called getName and setName respectively. Also, for your class to work properly with the <jsp:useBean/> tag, you should also have a default, no arguments constructor. This is (basically) what makes it a JavaBean.
Hope that helps...
Regards
Simon
------------------
Simon Brown
Co-author of Professional JSP 2nd Edition
 
wood burning stoves
 
subject: JSP's and class files.....
 
Similar Threads
Help on JSP's in VAJ 4.0 and Websphere Test Enviornment
What Class diagrams comprise, finally
Tomcat JSP does not recognizes my java classes
Class not found errors for JSPs in sub-directories
Same Form, More than Once