|
This example will use a Java bean to create a simple hit counter. There's nothing complicated about Java beans. Java beans are just Java classes that follow some simple naming conventions. Resin makes creating beans simple. Resin will automatically compile Java source in the directory.With the configuration you're using now, is in:
JSP encourages beans with the jsp:useBean tag. JSP will automatically create a new bean and store it in the application object. The example creates a Counter bean and stores it in the application object. Each request calls getHit() to get the next value of the counter.
The source of the bean looks like:
Now, create the bean in the bean directory and load counter.jsp:
You should then make some changes to Counter.java and reload to see the auto-recompilation. Also, introduce some errors to get familiar with the error reporting. You can also compile the bean separately and then put Counter.class in
The special tag translates into standard JSP. Here's the translation:
In a real development environment, your Java source directory may be different from the web server directory. The resin.conf lets you select any directory as the Java source and Java classes.
|