Test your basic authentication servlet

A servlet can use basic authentication to log in to PolicyCenter. This procedure shows you how to test a basic authentication servlet.

Before you begin

This topic uses the mycompany.test.TestingServlet servlet, as shown in Example of a basic authentication servlet. To test the servlet, you must use a tool that supports adding HTTP basic authentication headers for the user name and password.

Procedure

  1. Run the QuickStart server with the following command:
    gwb runServer
  2. Test the servlet at the URL:
    http://localhost:8180/pc/service/test

    The text "/test" in the URL is the part that matches the servlet string. Change the port number and the server name to match your PolicyCenter application.

  3. In the authentication dialog box that appears, type valid login credentials.

    The following text appears on the page:

    I am the page /test

    The following messages appear in the console in Studio:

    servlet test url: /pc/service/test
    query string: null
  4. Test additional pages:
    http://localhost:8180/pc/service/test/is/this/working?param=value

    The following text appears on the page:

    I am the page /test/is/this/working

    The following messages appear in the console in Studio:

    servlet test url: /pc/service/test
    query string: param=value
  5. To test the HTTP basic authentication without using the default login dialog:
    1. Close your browser to remove the session context.
    2. Re-test your servlet, using a tool that supports adding HTTP headers for HTTP basic authentication.