Use the checklist below as a guide for setting up a DbForms application.
Copy the file
bin/dbforms.tld
from the DbForms
distribution into the WEB-INF
directory of your web application.
Note. The file
dbforms.tld
was named
taglib.tld
in some prior
versions. The name taglib.tld
was
changed because it was too generic and the risk of naming conflicts
too great.
bin/dbforms
X.Y.jar
(where X.Y is the release number) from the DbForms
distribution into the
WEB-INF/lib
directory of
your web application.
dependend
directory of the DbForms
distribution into the WEB-INF/lib
directory of your web application.
WEB-INF/web.xml
file to
include the following items. See Section 4.3.1, “Edit deployment descriptor web.xml
” for
more details.
servlet
elements to
define the control, config, and file servlets and their
URL mappings. Other servlets may also be needed for
additional capabilities such as JasperReports, Excel
output, and CSV output.
WEB-INF/dbforms-config.xml
that defines the tables, the fields, and the database connection
to use. See
Chapter 8, Configuration Files
for details of the
contents of this file. This can be generated AUTOMATICALLY
(along with JSP pages) by using the DevGui application. See
Chapter 5, DevGui
for more information.
It is also possible to use more than one configuration
file. Simply list them with commas between them in the
dbformsConfig
init param
of the ConfigServlet
in
web.xml
as shown in this
fragment from the
dbforms-config.xml
file.
<init-param> <param-name>dbformsConfig</param-name> <param-value> /WEB-INF/dbforms-config.xml,/WEB-INF/custom/dbforms-config.xml </param-value> </init-param>
WEB-INF/dbforms-errors.xml
file that defines error messages. See the
xmlErrors
tag in the separate DbForms Custom Tag Library document in
the
docs/taglib
directory for more information.
<%@ taglib uri="/WEB-INF/dbforms.tld" prefix="db" %>The prefix "
db
" followed
by a colon is placed in front
of each tag from the DbForms tag library. The above declaration
gives the association between the tag library and the prefix.
If you wish, you can use a prefix other that
"db
".
This document, however, assumes a prefix of
"db
".
dbforms-config.xml
is really working. Whether this is an easy task or not,
depends heavily on the database server you are using. One way to do
this is to use the database tab in DevGui
(Section 5.4.2, “Database Tab”)
to set up a simple, non-JNDI and non-connection pool connection.
Common reasons for database-related problems are:
The listing shown below is a complete deployment descriptor for a DbForms application. If the web application has additional servlets in addition to the servlets that comprise DbForms, they would be added to the descriptor in the normal manner.
The order of elements in
web.xml
is important so be sure to follow the DTD/Schema. For
convenience, the top level of the root element
web-app
is shown below.
<!ELEMENT web-app (icon?, display-name?, description?, distributable?, context-param*, filter*, filter-mapping*, listener*, servlet*, servlet-mapping*, session-config?, mime-mapping*, welcome-file-list?, error-page*, taglib*, resource-env-ref*, resource-ref*, security-constraint*, login-config?, security-role*, env-entry*, ejb-ref*, ejb-local-ref*)>
Add the following
servlet
,
servlet-mapping
,
taglib
,
and
context-param
(optional)
elements to the
web-app
element in the
/WEB-INF/web.xml
file.
The sample listing below has portions keyed to remarks that follow.
<?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <!--============= DBFORMS STYLING TEMPLATES =============--> <context-param> <param-name>templateBase</param-name> <param-value>templates</param-value> </context-param> <!--=========== DbForms Configuration Servlet ===========--> <servlet> <servlet-name>config</servlet-name> <servlet-class>org.dbforms.servlets.ConfigServlet</servlet-class> <init-param> <param-name>log4j.configuration</param-name> <param-value>/WEB-INF/log4j.properties</param-value> </init-param> <init-param> <param-name>digesterDebugLevel</param-name> <param-value>0</param-value> </init-param> <init-param> <param-name>resourceBundle</param-name> <param-value>ApplicationResources</param-value> </init-param> <init-param> <param-name>validation</param-name> <param-value>/WEB-INF/validation.xml</param-value> </init-param> <!--More than one validation file is possible--> <!--init-param> <param-name>validation</param-name> <param-value>/WEB-INF/validation.xml</param-value> </init-param--> <init-param> <param-name>validator-rules</param-name> <param-value>/WEB-INF/validator-rules.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!--=========== DbForms Controller Servlet ==============--> <servlet> <servlet-name>control</servlet-name> <servlet-class>org.dbforms.servlets.Controller</servlet-class> <init-param> <param-name>maxUploadSize</param-name> <param-value>80000</param-value> </init-param> </servlet> <!--=========== DbForms FileServlet =====================--> <servlet> <servlet-name>file</servlet-name> <servlet-class>org.dbforms.servlets.FileServlet</servlet-class> <load-on-startup>2</load-on-startup> </servlet> <!--==== Controller Servlet and FileServlet Mappings========--> <servlet-mapping> <servlet-name>control</servlet-name> <url-pattern>/servlet/control</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>file</servlet-name> <url-pattern>/servlet/file</url-pattern> </servlet-mapping> <!--=========== Session config =====================--> <session-config> <session-timeout>30</session-timeout> </session-config> <!--=========== Welcome File List =====================--> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!--=========== DbForms Tag Library Descriptor ==========--> <taglib> <taglib-uri>/WEB-INF/dbforms.tld</taglib-uri> <taglib-location>/WEB-INF/dbforms.tld</taglib-location> </taglib> <!--=========== Application Security Controls ==========--> </web-app>
Remarks:
This is optional. See Section 11.3.4.1, “Template base directory ” for more information. | |
The initialization parameter
Now that log4j handles all console output, you would
think that by setting log4j to display fatal errors
only, your console would be virtually empty. Well, no!
The current version of DbForms uses the struts digester
class to parse xml files at startup. This class sends
info to System.out. The initialization parameter
Sample log4j.properties file: #begin log4j.props #IMPORTANT - Watch for trailing whitespaces after each statement!!! #log4j.rootCategory=debug, stdout, logFile #log4j.rootCategory=warn, stdout log4j.rootCategory=error, stdout log4j.category.org.dbforms=warn #out to console log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout # Pattern to output the caller's file name and line number. log4j.appender.stdout.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n #out to file log4j.appender.logFile=org.apache.log4j.RollingFileAppender log4j.appender.logFile.File=c:\log4j\dbforms.txt #log4j.appender.logFile.File=/var/tomcat/logs/dbforms.log log4j.appender.logFile.MaxFileSize=100KB log4j.appender.logFile.MaxBackupIndex=1
| |
DbForms v1.1 supports internationalization
(i18n). Labels, messages, etc. can be stored in
"resource bundle" files and retrieved using appropriate
DbForm tags. The optional initialization parameter
| |
Enhanced validation features are available because
the Apache Commons-Validator framework has been integrated
into DbForms. This framework requires the use of two
distinct xml descriptor files. The optional
initialization parameters
| |
The initialization parameter
|
DbForms inherits all of the security controls present in the servlet container, either an application server or a dedicated servlet engine such as Tomcat. Therefore, please refer to documentation for the Application Server or Servlet Engine being used for information on this topic. The Java Servlet specification also contains information about web application security.
A typical security-aware web application deployment
descriptor has elements inside its
web-app
element as shown below.
<!-- ==================================================== --> <!-- = APPLICATION SECURITY = --> <!-- ==================================================== --> <!-- =================== authentication ================= --> <!-- We protect everything in directory /protected however, be sure NOT to protect login.jsp or logout.jsp since, in most containers, this would lead to endless recursion which ends with a crash of the Java Virtual Machine ("StackOverFlow") --> <security-constraint> <web-resource-collection> <web-resource-name>myapp</web-resource-name> <url-pattern>/protected/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>a_users</role-name> <role-name>b_users</role-name> <role-name>guests</role-name> </auth-constraint> </security-constraint> <!--=================== login config ====================--> <login-config> <auth-method>FORM</auth-method> <realm-name>Form-Based Authentication Area</realm-name> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/login.jsp</form-error-page> </form-login-config> </login-config> <!--<login-config> <auth-method>BASIC</auth-method> <realm-name>Example Basic Authentication Area</realm-name> </login-config>--> <!--=================== roles ===========================--> <security-role> <description>Have read only access</description> <role-name>guests</role-name> </security-role> <security-role> <description>Registered users can do stuff, others not.</description> <role-name>a_users</role-name> </security-role> <security-role> <description>Registered users can do less then users_a</description> <role-name>b_users</role-name> </security-role>
Remarks:
User authentication and mapping of users to roles are both
performed by the servlet container. For Tomcat, this is
controlled via the Realm
element in the conf/server.xml
file.
DbForms provide some additional security controls beyond the controls inherited through the container. See Chapter 9, Security for fine-grained definition of rights for data access and manipulation.
Finally, here a short list of files to check when deploying a web application using DbForms:
Example 4.1. Structure of a typical DbForm application
Bold items are required.
/yourfile1.jsp /yourfile2.jsp /yourfile1.html /yourfile2.html /yourfile1.css ../templates/yourTemplateA/yourTemplateA_begin.jsp ../templates/yourTemplateA/yourTemplateA_end.jsp ../templates/templateB/templateB_begin.jsp ../templates/templateB/templateB_end.jsp /WEB-INF/web.xml /WEB-INF/dbforms-config.xml /WEB-INF/dbforms.tld /WEB-INF/log4j.properties /WEB-INF/validation.xml /WEB-INF/validator-rules.xml /WEB-INF/lib/dbforms2.X.Y.jar /WEB-INF/lib/cactus-13-1.7dev20041109.jar /WEB-INF/lib/cewolf-0.10.1.jar /WEB-INF/lib/commons-beanutils-1.6.jar /WEB-INF/lib/commons-collections-2.1.jar /WEB-INF/lib/commons-dbcp-1.1.jar /WEB-INF/lib/commons-digester-1.5.jar /WEB-INF/lib/commons-el-1.0.jar /WEB-INF/lib/commons-fileupload-1.0.jar /WEB-INF/lib/commons-httpclient-2.0.jar /WEB-INF/lib/commons-lang-2.0.jar /WEB-INF/lib/commons-logging-1.0.3.jar /WEB-INF/lib/commons-pool-1.1.jar /WEB-INF/lib/commons-validator-1.0.2.jar /WEB-INF/lib/hsqldb-1.7.1.jar /WEB-INF/lib/httpunit-1.5.4.jar /WEB-INF/lib/itext-1.01.jar /WEB-INF/lib/jasperreports-0.6.4.jar /WEB-INF/lib/jcommon-0.9.6.jar /WEB-INF/lib/jfreechart-0.9.21.jar /WEB-INF/lib/junit-3.8.1.jar /WEB-INF/lib/log4j-1.2.8.jar /WEB-INF/lib/maxq-0.95dev.jar /WEB-INF/lib/nekohtml-0.9.3.jar /WEB-INF/lib/oro-2.0.8.jar /WEB-INF/lib/poi-2.0-final-20040126.jar /WEB-INF/lib/protomatter-1.1.8-pre5.jar /WEB-INF/lib/rhino-1.5R4.1.jar /WEB-INF/lib/servletapi2.3 /WEB-INF/lib/servletapi2.4 /WEB-INF/lib/xalan-2.5.1.jar /WEB-INF/lib/xercesImpl-2.6.0.jar /WEB-INF/lib/xmlParserAPIs-2.2.1.jar /WEB-INF/classes/your_package/yourservlet1.class /WEB-INF/classes/your_package/yourservlet2.class /WEB-INF/classes/your_package/yourinterceptorI.class /WEB-INF/classes/your_package/yourinterceptorII.class /WEB-INF/classes/...
Remarks
The above list of required JAR files is dependent on the version of
DbForms being used and also dependent on features of DbForms
used in the application. The list is current as of
version 2.5 but it is prudent to check the contents of directory
dependend
in the binary distribution
since that directory defines the official set of dependencies.
The JDBC driver may, in some cases such as for simple connections,
be placed in the
WEB-INF/lib
directory.
For Tomcat, the directory common/lib
may also be used to place the DbForms JAR file and other dependencies
in a single location that can be shared among multiple DbForms
applications.
Other dependencies, such as JDBC drivers may be placed in Tomcat directory
server/lib
where they may be used
by Tomcat to be shared among all web applications in the container.
In some cases, when there is a verson conflict between a
DbForms dependency and the same library needed by the servlet
container, a JAR file must be placed in the
server/lib
directory (or its
equivalent in a container other than Tomcat) instead of the
application's WEB-INF/lib
directory.