This section describes how to create, secure, and deploy web applications using Sun Java System Web Server 7.0.
This section lists the general actions to create a web application, and provides pointers to more information.
Create a directory for all of the web application's files. This directory is the web application's document root.
Create any needed HTML files, image files, and other static content.
Place these files in the document root directory or a subdirectory where they can be accessed by other parts of the application.
Create any needed JSP files.
For more information, see Chapter 5, Developing JavaServer Pages
Create any needed servlets.
For more information, see Chapter 4, Developing Servlets.
Compile the servlets.
For details about precompiling JSPs, see Compiling JSPs Using the Command-Line Compiler.
Organize the web application as described in Web Application Structure.
Create the deployment descriptor files.
For more information, see Creating Web Deployment Descriptors.
jar -cvf module_name.war *.
Deploy the web application. For more information, see Deploying Web Applications.
You can create a web application manually or you can use Java System Enterprise Studio. For more information about developing web applications in Sun Java Enterprise Studio, see http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
You can write secure web applications for the Sun Java System Web Server with components that perform user authentication and access authorization. You can build security into web applications using the following mechanisms:
User authentication by servlets
User authentication for single sign-on
User authorization by servlets
Requesting the client certificate
For detailed information about these mechanisms, see Chapter 8, Securing Web Applications.
A web application is a collection of servlets, JSP, HTML documents, and other web resources that might include image files, compressed archives, and other data. A web application can be packaged into a Web ARchive file (a WAR file) or exist in an open directory structure. For more information, see Chapter 9, Deploying Web Applications.
A virtual server is a virtual web server that uses a unique combination of IP address, port number, and host name to identify it. You might have several virtual servers all of which use the same IP address and port number but are distinguished by their unique host names.
When you first install Sun Java System Web Server 7.0, a default virtual server is created. You can also assign a default virtual server to each new HTTP listener you create. For details, see Sun Java System Web Server 7.0 Administrator’s Guide.
A web application that is deployed in a virtual server at a URL / becomes the default web application for that virtual server. To access the default web application for a virtual server, type the URL for the virtual server but do not supply a context root. For example:
If none of the web applications under a virtual server are deployed at the URI ”/”, the virtual server serves HTML or JSP content from its document root, which is usually instance_dir/docs. To access this HTML or JSP content, point your browser to the URL for the virtual server specify the target file rather than a context root. For example:
The Sun Java System Web Server 7.0 can cache servlet or JSP results to make subsequent calls to the same servlet or JSP page faster.
For more information about response caching as it pertains to servlets, see Caching Servlet Results.
JSP cache tags enable you to cache JSP page fragments within the Java engine. Each can be cached using different cache criteria. For example, if you have page fragments to view stock quotes and weather information, you can cache the stock quote fragment for 15 minutes, and the weather report fragment for 25 minutes.
For more information about JSP caching, see JSP Cache Tags.
Database connection pooling enhances the performance of servlet or JSP database interactions. For more information about the JavaTM DataBase Connectivity (JDBCTM) software, see Configuring JDBC Resources in Sun Java System Web Server 7.0 Administrator’s Guide.
The simplest connection pool can be configured by using the given. In this example, the connection pool is assigned to use the ORACLE JDBC driver.
In this example procedure, the connection pool uses the ORACLE JDBC driver.
$ ./bin/wadm --user=admin Please enter admin-user-password>user-admin-password Sun Java System Web Server 7.0 B01/02/2006 14:22 wadm>
Verify the list of available configurations.
Create the jdbc-resource configuration.
For more information about all possible elements, see Sun Java System Web Server 7.0 Administrator's Configuration File Reference.
wadm>create-jdbc-resource --config=test --datasource-class=oracle.jdbc.pool.OracleDataSource jdbc/MyPool
Add properties to jdbc-resource.
Properties are primarily used to configure the driver's vendor-specific properties. In the following example, the values for the properties url, user, and password are added to jdbc-resource.
wadm>list-jdbc-resource-userprops --config=test --jndi-name=jdbc/MyPool password=mypassword user=myuser url=jdbcZ:oracle:thin:@hostname:1421MYSID
Enable the connection validation.
wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool connection-validation-table-name=test connection-validation=table CLI201 Command "set-jdbc-resource-prop" ran successfully
Change the pool setting.
In this example, the maximum number of connections is set to 100.
wadm>set-jdbc-resource-prop --config=test --jndi-name=jdbc/MyPool max-connections=100 CLI201 Command "set-jdbc-resource-prop" ran successfully.
Deploy the configuration.
wadm>deploy-config test CLI201 Command "deploy-config" ran successfully.
You can install a JDBC driver with Java Archive (JAR) files in one of the following ways:
Copy the driver's JAR file into the server's instance library directory. JAR files in the instance library directory will automatically load and available for server.
Modify the JVM class-path- suffix to include JDBC drivers jar file. The new value will overwrite the old value of the element. For example, wadm> set-jvm-prop --config=test class-path-suffix=/export/home/lib/classes12.jar