File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Having problem when using web.xml to provide login system to user. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Having problem when using web.xml to provide login system to user." Watch "Having problem when using web.xml to provide login system to user." New topic
Author

Having problem when using web.xml to provide login system to user.

Rudy Rusli
Ranch Hand

Joined: Jun 01, 2006
Posts: 114
I'm trying to build a login system into my webapps.
Below is my web.xml and my tomcat-users.xml. I try to login using "myRole" and "myPassword" but it doesn't work. It keeps showing me the pop-up box until it fails to login and gives me HTTP error 401.
I'm using Tomcat 4.1.29.

Could somebody please advice?

Thanks

----------------------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<resource-env-ref>
<description>Link to the UserDatabase instance from which
we request lists of defined role names.</description>
<resource-env-ref-name>UserDatabase</resource-env-ref-name>
<resource-env-ref-type>org.apache.catalina.UserDatabase</resource-env-ref-type>
</resource-env-ref>

<security-constraint>
<web-resource-collection>
<web-resource-name>user-resource</web-resource-name>
<description>pages which require login</description>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.htm</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>

<auth-constraint>
<description>Must authenticate before querying the system</description>
<role-name>myRole</role-name>
</auth-constraint>

<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>

<login-config>
<auth-method>DIGEST</auth-method>
<realm-name>TEST PAGE</realm-name>
</login-config>

<security-role>
<description>...</description>
<role-name>myRole</role-name>
</security-role>

</web-app>
----------------------------------------------------------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="myRole"/>
<user username="myRole" password="myPassword" roles="myRole"/>
</tomcat-users>
----------------------------------------------------------------------------------------
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having problem when using web.xml to provide login system to user.