Overview 

 

Package examples.webapp.cookie

This example demonstrates the Web Application Archive (WAR) format and how a Web Application is deployed and accessed from a browser client. This example demonstrates how servlets and served files (.html, .jsp, and image files) must be packaged when deployed in a WAR file.

Component Description
web.xml Web Application deployment descriptor that configures a servlet, a welcome file (.html), and an error page (.jsp).
error.jsp Error page for the cookie Web Application.
hello.html Welcome page for the cookie Web Application.
cookie.jpg Image file displayed in by the CookieCounterServlet servlet
CookieCounterServlet.java The CookieCounter servlet from the examples.servlets package is compiled and packaged into the WAR file created in this example.

Build the Example

  1. Set up your development shell

  2. Move to the sample directory:

    cd $WL_HOME/samples/server/examples/src/examples/webapp/cookie

  3. Compile the example by executing the ant build script:

    ant

    The build script automatically compiles the servlet, packages the Web Application into a WAR file, and places the WAR file into the /applications directory where it is automatically deployed. The build script performs the following steps:

    • Creates a staging directory named build for the Web Application. This includes a WEB-INF subdirectory which is used to store the Web Application deployment descriptor, web.xml, and the classes required by the Web Application.

    • Copies the deployment descriptor and files into the appropriate locations in the staging directory.

    • Compiles the CookieCounterServlet servlet from the examples.servlets package into the WEB-INF/classes subdirectory of the staging directory.

    • Creates a WAR file using the jar command and saves the WAR file into the /applications directory.

    • Start WebLogic Server with the examples configuration.

  4. Load the cookie Web Application

    http://www.setgetweb.com:7001/cookie

  5. Follow the "Click here" link.