Sun GlassFish Enterprise Server 

Samples Main Page

Servlet 3.0 HTTP Method Omission Sample

This sample demonstrates the use of http-method-omission feature of Servlet 3.0  to restrict the set of supported HTTP methods to just GET and POST.

Building, Deploying, and Running the Application

Perform the following steps to build, deploy, and run the application:

  1. Setup your build environment and configure the application server with which the build system has to work by following the common build instructions.
  2. app_dir is the sample application base directory: samples_install_dir/javaee6/security/http-method-omission.
  3. Change directory to app_dir.
  4. Open the browser and clear the browser cache.
  5. Build, deploy, and run the sample application:
  6.         app_dir> ant

  7. The launch target opens the browser. Try the Post method to see a challenge posed to the user to enter username/password.Enter javaee6user/abc123 (the configured file-user for role javaee6user). Try the Get method to check that all users are denied access.

  8. Use the target clean to undeploy the sample application and to remove the temporary directories like build and dist.

    app_dir> ant clean

Building, Deploying, and Running the Application in NetBeans IDE

Follow these instructions to build, deploy, and run this sample application using NetBeans IDE.

  1. Download and install Netbeans IDE 6.7. For setting up NetBeans IDE and the application server, see the common build instructions.
  2. In NetBeans IDE, select File->OpenProject and select samples_install_dir/javaee6/security/http-method-omission as the project.
  3. In Tools->Servers, add a new glassfish v3 server (taken from the Glassfish Javaone release) and start the server
  4. Access the adminconsole of the server (http://localhost:4848) and go to the Security->Realms->FileRealm node in the tree.
  5. Click the Manage Users button on the Edit Realm page to add a new user (UserID, Group List - javaee6user, password - abc123)
  6. Right click on http-method-omission and select Run Project which will build, deploy and run the project.
  7. Try the Post method to see a challenge posed to the user to enter username/password.Enter javaee6user/abc123 (the configured file-user for role javaee6user). Try the Get method to check that all users are denied access.

Troubleshooting

If you have problems when running the application, refer the troubleshooting document.

 


Copyright 2009 Sun Microsystems, Inc. All rights reserved.