|
|
|
| kinetic Home | kinetic Manager | E-mail Services | Web Site Management | USENET News | Modem Pools |
| Home > Web Site Management > Java Application Server > Web Applications > Web Application Design Guidelines |
View the printer friendly version of this document |
Web Application Design GuidelinesRevised: April 14, 2003 Important: The Java application server and MySQL database are not included as part of the kinetic Service annual fee. These technologies are available on an as-requested basis for an additional fee. Contact David Drum at david@more.net or (800) 509-6673 for additional information. Contents
OverviewThis document provides technical guidelines to use when designing a Java web application for deployment on a server hosted as part of the kinetic Service. It includes information about the server environment and configuration to make it easier for you to develop and deploy a web application. Application design best practices are also discussed to help you design your web application so that it runs efficiently, reduces request latency, and scales well as traffic to your web site grows. Tomcat 4 Application ServerTomcat 4 is installed as the application server (servlet container) in which your web applications run. Tomcat 4 implements the Java Servlet 2.3 and JavaServer Pages (JSP) 1.2 specifications. Tomcat is installed on a Sun Sparc server running the Solaris 8 UNIX OS with the latest released version of the Java 1.3 JVM from Sun. Tomcat 4 runs with the Java SecurityManager enabled and a strict Java security policy. Apache Web ServerThe Apache web server is used to serve requests for web pages from your web site. A recent version of Apache 2.0 is installed on a Sun Sparc running the Solaris 8 UNIX OS.
Apache uses mod_jk to connect to Tomcat and pass along any requests
for servlets or JSPs in your web applications.
The Apache mod_jk module is configured to forward all requests for
HTTP requests for the following directories and files return the HTTP 403 error code (Access Forbidden):
You can use Apache Static files within your web applications, such as image and html files, are served directly by Apache. This is more efficient than having Tomcat serve all requests. Caution: Apache will not honor any security restraints you specify in your web application Web application WAR files and web application directories can be placed in the /www directory, the root directory for web site content. The Apache web server has Server Side Include (SSI) enabled for all
files which have the file extensions Note: For performance reasons the Apache web server does not resolve the IP addresses of remote clients to their hostname. Because of this the Java APIs Installed with TomcatThe most recently released versions of the following Java APIs
are available for use by your web application. There is no
need for your web application to install these in its
MySQL Database UsageA recent version of MySQL 3.23 is installed on a Sun Sparc running Solaris 8 UNIX OS. Establishing a Database ConnectionThe application server provides an easy way for your application to establish a connection to the database for your web site. The server supports use of the Java Naming and Directory Interface (JNDI) to access a Java DataBase Connection (JDBC). A JNDI named JDBC DataSource is made available for use by any web application you install in Tomcat for your web site. The JNDI name for this connection is:
Your application can use the JNDI named JDBC DataSource either by using the DBTags JSP Tag Library, the JSP Standard Tag Library, or directly using Java code. See the Creating Your First Database-enabled Web Application Tutorial for an example of using DBTags with a JNDI named JDBC DataSource. Database Connection PoolingDatabase connection pooling improves the performance of applications which use a database by maintaining a pool of database connections and reusing them. Establishing a new connection to a database delays page processing and can be the main source of latency between the time a page is requested and the time it is returned to the site visitor. Use of a connection pool improves the performance of your application. The JNDI named JDBC DataSource provided by the application server implements database connection pooling for you. If your application uses the JNDI named JDBC DataSource, there is no need for your application to implement database connection pooling. Caution: Your application must make sure it closes each JDBC ResultSet, Statement, and Connection. Failure to close these prevents that database connection from being re-used. This results in your application failing due to not being able to get a connection to the database. Database Object CachingDatabase object caching is a middleware technology used to persist and cache objects from a database and can significantly improve performance. Specifically, an object cache addresses performance issues such as delays from database query latency and unnecessary thrashing of the JVM for creation and subsequent garbage collection of objects created for result sets. The Jakarta Object Relational Bridge project: http://jakarta.apache.org/ojb has additional information for those interested in this type of performance tuning. MySQL PrivilegesMySQL uses an access privilege system to implement security. The following MySQL privileges are granted to the database connection your application uses:
Efficient use of MySQLSee the MySQL Best Practices document for information on how to best use and not abuse the MySQL database. Sending E-mailThe application server provides an easy way for your application to send e-mail. The server supports use of the Java Naming and Directory Interface (JNDI) to send e-mail via a JavaMail MimePartDataSource. A JNDI named MimePartDataSource is made available for use by any web application you install in Tomcat for your web site. The JNDI name for this connection is:
Your application can use the JNDI named MimePartDataSource either by using the Mailer JSP Tag Library or directly using Java code. See the JSP examples which come with the kinetic Tomcat4 Local Development distribution for an example of using the Mailer JSP Tag Library with a JNDI named MimePartDataSource. PortabilityPlease design the web application so that it is self contained and portable between your development server and the production server. If you don't have to make any changes when installing the web application on the production server, maintenance and updating of your application will be easier and less error prone. Here are some tips for keeping your application portable: Use of file based resourcesFile based resources within the web application should be obtained using a web application context relative path so that the application is portable between the development server and the production server. For more information, see the Java documentation for the ServletContext getResource() methods. Database AccessUse the JNDI named JDBC DataSource for database access. This abstracts out the database, connection, user, and password from the application so it can be seamlessly moved between the development server and the production server. Remote Client SessionsA servlet container can store information about a remote user's usage of your application by using a Session. A Session should not be created for a remote client (user) unless you need to track information about the user's usage of your application between HTTP requests. Creating Sessions for remote users when your application doesn't need them creates additional unnecessary work for the servlet container. If your applications use JavaServer Pages (JSP), the default behavior of a JSP page is to create a Session. Please use the following JSP page directive at the top of each JSP page to explicitly disable Sessions if you don't need them:
General Tips for Application Design
Please do not turn your entire web site into a web application using JSP
pages. This is not very efficient. Apache serves
static files much faster than Tomcat serves dynamic content generated from
JSP. Serving as much content as possible using static Do not design your site to use JSP for generating HTML for content that changes infrequently. You might be tempted to store news stories, announcements, etc. in the database and then use JSP to generate pages for your web site. If this content, which resides in the database, changes infrequently (several dozen times a day), you are essentially using JSP to serve mostly static content. In this case we recommend that you use a build system which generates static html pages from the content of the database, and then publish those static pages to your web site. This will make your site more efficient and reliable. If your application uses JSP, try to avoid embedding Java code in the JSP. Try to use JSP tags and JSP custom tag libraries instead. This will make your JSP pages much easier to maintain and less prone to failure. If your application requires business logic, put that logic in Java Beans or your own JSP custom tag library.
If you have a page on your web site which only has a small portion of
it generated by JSP, create the page as a |
|
kinetic Home |
kinetic Manager |
E-mail Services |
Website Management |
USENET News |
Modem Pools Copyright © 2002-2008 Curators of the University of Missouri. All rights reserved. Copyright, accessibility, privacy and other information about this site. DMCA and other copyright information. Acceptable Use Policy |