This example uses 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 WEB-INF/classes directory.
With the configuration you're using now, WEB-INF/classes 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
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 jsp:useBean 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.
Copyright (c) 1998-2009 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.