Files   Prepare   Run   Troubleshooting   Related Topics 

About the Example

This example demonstrates how to use the WebLogic-specific servlet metadata annotations @WLServlet and @WLFilter. By using these annotations in your Java class you do not have to configure the Servlet and Filter, respectively, in the web.xml file.

 


Files Used in the Example

Directory Location:

BEA_HOME/wlserver_10.3/samples/server/examples/webapp/servlets/annotations/extension

(where BEA_HOME is the directory containing your WebLogic Server installation)

File

Click source files to view code.

Description

application.xml The Java EE standard enterprise application deployment descriptor.
build.xml Ant build file that contains targets for building and running the example.
ExamplesFooter.jsp Java Server Page containing the Example Footer.
ExamplesHeader.jsp Java Server Page containing the Example Header.
HelloworldServlet.java Simple Servlet that demonstrates how to use the @WLServlet annotation.
LoginFilter.java Servlet Filter that authenticates requests for HelloworldServlet.
loginForm.jsp Login form page for the WebLogic extended annotations example Web Application.
web.xml The standard Web application deployment descriptor.

Prepare the Example

Prerequisites

Before working with this example:

  1. Install WebLogic Server, including the examples.
  2. Start the Examples server.
  3. Set up your environment.

Configure WebLogic Server

  No special configuration is required for this example

Build and Deploy the Example

To build the example, follow these steps:

  1. Change to the SAMPLES_HOME\server\examples\src\examples\webapp\servlets\annotations\extension directory, where SAMPLES_HOME refers to the main WebLogic Server examples directory, such as d:\bea\wlserver_10.3\samples.
  2. Execute the following command:

    ant build

    This command compiles and stages the example.
  3. Execute the following command:

    ant deploy

    This command deploys the example on the wl_server domain of your WebLogic Server installation.

    The Ant command uses the build.xml file, located in the SAMPLES_HOME\server\examples\src\examples\webapp\servlets\annotations\extension directory, to build the example.

     


Run the Example

To run the example, follow these steps:

  1. Complete the steps in the "Prepare the Example" section.
  2. In your development shell, run the example by executing the following command from the example directory (SAMPLES_HOME\server\examples\src\examples\webapp\servlets\annotations\extension):

    prompt> ant run

    This command executes the build.xml run target, which opens your default browser to the following URL:

    http://localhost:port/ext_servlet_annotations/

    where

localhost refers to the machine on which WebLogic Server is running

port refers to port on which WebLogic Server is listening

  1. If your example runs successfully, you will see the HelloWorldServlet page after you submit the loginForm with the correct username and password .

Troubleshooting


Related Topics

(Internet connection required.)


Copyright © 1996, 2008, Oracle and/or its affiliates. All Rights Reserved.