Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rudy Rusli
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
----------------------------------------------------------------------------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic