background image

Building Servlet Basic Authentication Example

<< Adding Authorized Roles and Users | Running Basic Authentication Servlet >>
<< Adding Authorized Roles and Users | Running Basic Authentication Servlet >>

Building Servlet Basic Authentication Example

<sun-web-app>
<context-root>/hello2_basicauth</context-root>
<security-role-mapping>
<role-name>helloUser</role-name>
<group-name>user</group-name>
</security-role-mapping>
</sun-web-app>
Building, Packaging, and Deploying the Servlet Basic Authentication
Example Using NetBeans IDE
To build, package, and deploy the web/hello2_basicauth example application using NetBeans
IDE, follow these steps:
1. If you have not already done so, follow the instructions in
"Building the Examples" on
page 70
. This step is necessary to provide the Ant targets with the location of your tutorial
and Application Server installations.
2. If you have not already done so, add authorized users to the file realm of the Application
Server as described in
"Adding Authorized Roles and Users" on page 881
.
3. Open the project in NetBeans IDE by selecting File
Open Project.
4. Browse to the tut-installjavaeetutorial5/examples/web/hello2_basicauth/ directory.
5. Make sure that Open as Main Project is selected.
6. Select Open Project Folder.
7. Right-click hello2_basicauth in the Projects pane, then select Clean and Build Project.
8. Right-click hello2_basicauth in the Projects pane, then select Deploy Project.
9. To run the servlet, follow the steps in
"Running the Basic Authentication Servlet" on
page 883
.
Building, Packaging, and Deploying the Servlet Basic Authentication
Example Using Ant
To build, package, and deploy the web/hello2_basicauth example using the Ant tool, follow
these steps:
1. If you have not already done so, follow the instructions in
"Building the Examples" on
page 70
. This step is necessary to provide the Ant targets with the location of your tutorial
and Application Server installations.
2. If you have not already done so, add authorized users to the file realm of the Application
Server as described in
"Adding Authorized Roles and Users" on page 881
.
3. From a terminal window or command prompt, change to the
tut-install/javaeetutorial5/examples/web/hello2_basicauth/ directory.
4. Build and package the web application by entering the following command at the terminal
window or command prompt:
Examples: Securing Web Applications
The Java EE 5 Tutorial · September 2007
882