C Web Application Best Practices

The following sections contain Oracle best practices for designing, developing, and deploying WebLogic Web applications and application resources:

CGI Best Practices

The following are CGI best practices with respect to calling a subscript:

  • You can use sh subscript.sh for both exploded (unarchived) Web applications and archived Web applications (WAR files).

  • You can use sh $PWD/subscript.sh for both exploded (unarchived) Web applications and archived Web applications (WAR files).

  • You can use sh $DOCUMENT_ROOT/$PATH/subscript.sh for exploded (unarchived) Web applications. You cannot use it, however, for archived Web applications (WAR files). This is due to the fact that the document root might point you to the root of your WAR file, and the scripting language cannot open that WAR file and locate the subscript.sh needed for execution. This is true not only for sh, but for any scripting language.

Servlet Best Practices

Consider the following best practices when writing HTTP servlets:

  • Compile your servlet classes into the WEB-INF/classes directory of your Web application.

  • Make sure your servlet is registered in the J2EE standard Web applications deployment descriptor (web.xml).

  • When responding to a request for a servlet, WebLogic Server checks the time stamp of the servlet class file prior to applying any filters associated with the servlet, and compares it to the servlet instance in memory. If a newer version of the servlet class is found, WebLogic Server re-loads all servlet classes before any filtering takes place. When the servlets are re-loaded, the init() method of the servlet is called. All servlets are reloaded when a modified servlet class is discovered due to the possibility that there are interdependencies among the servlet classes.

    You can set the interval (in seconds) at which WebLogic Server checks the time stamp with the Servlet Reload attribute. This attribute is set on the Files tab of your Web application, in the Administration Console. If you set this attribute to zero, WebLogic Server checks the time stamp on every request, which can be useful while developing and testing servlets but is needlessly time consuming in a production environment. If this attribute is set to -1, WebLogic Server does not check for modified servlets.

JSP Best Practices

For a complete explanation on how to avoid JSP recompilation, see Avoiding Unnecessary JSP Compilation at http://www.oracle.com/technology/index.html and specifically the section called "Scenarios that Cause Recompilation of JSPs."

Best Practice When Subclassing ServletResponseWrapper

J2EE provides the class javax.servlet.ServletResponseWrapper, which you can subclass in your Servlet to adapt its response.

Oracle recommends that if you create your own response wrapper by subclassing the ServletResponseWrapper class, you should always override the flushBuffer() and resetBuffer() methods. Not doing so might result in the response being committed prematurely.