File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes What's wrong with my Authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "What Watch "What New topic
Author

What's wrong with my Authentication

Marcelo Heitor
Greenhorn

Joined: Aug 20, 2005
Posts: 14
Hello folks,

I have a doubt on the chapter 12 of the book Head-First Servlets and JSP, I tried to do an authentication example in agreement with the book but I don't get to call the standard form of the browser, it follows the example

in tomcat-users.xml ********************************************
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="Guest"/>
<role rolename="Adm"/>
<role rolename="Member"/>
<user username="Annie" password="admin" roles="Adm,Member,Guest"/>
<user username="Diane" password="coder" roles="Member,Guest"/>
<user username="Ted" password="newBie" roles="Guest"/>
</tomcat-users>


in web.xml in my application, called Beer *********************************

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<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/web-app_2_4.xsd"

version="2.4">

<servlet>
<servlet-name>teste</servlet-name>
<servlet-class>AddRecipe.servletTeste</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>teste</servlet-name>
<url-pattern>/t.do</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>UpdateRecipes</web-resource-name>
<url-pattern>/Beer/*</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>Admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<realm-name></realm-name>
<auth-method>BASIC</auth-method>
</login-config>
<security-role>
<role-name>Adm</role-name>
</security-role>

</web-app>


and it follows the structure of pastes used in the application ************
-->webapps
-->Beer (with. jsp that calls a servlet through method get)
-->WEB-INF (with web.xml)
-->classes
-->AddRecipe (with servlet.class)

obs: It�s works, but I don't get to call the form of authentication of the browser
Zhing Lam
Greenhorn

Joined: Dec 06, 2004
Posts: 7
How do you type for request the resource? I mean, you type something like:
http://localhost:8080/yourapp/Beer/test.jsp
??


SCJP(1.4)
Marco Fung
Greenhorn

Joined: Jul 25, 2005
Posts: 7
In your tomcat setting, you use Admin.

but in your web.xml, you use a different name, Adm.
Marcelo Heitor
Greenhorn

Joined: Aug 20, 2005
Posts: 14
Folks, the code started to function suddenly, is stranger... but OK. I am thankful for the help!!!


Marcelo Heitor
Bras�lia - Brazil
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What's wrong with my Authentication