This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem on validatinfg role for security of </security-constraint> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem on validatinfg role for security of </security-constraint>" Watch "problem on validatinfg role for security of </security-constraint>" New topic
Author

problem on validatinfg role for security of </security-constraint>

Deep Mukherjee
Greenhorn

Joined: Jan 04, 2010
Posts: 20
I have created a JSP like this


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form method=GET action="TestServlet">
<INPUT TYPE=SUBMIT>
</form>
</body>
</html>


i have written the web,xml like this


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" 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">
<display-name>TestWebProject</display-name>
<servlet>
<description>
</description>
<display-name>TestServlet</display-name>
<servlet-name>TestServlet</servlet-name>
<servlet-class>com.test.java.TestServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<security-constraint>
<web-resource-collection>
<web-resource-name>IIMS</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>HEAD</http-method>
<http-method>PUT</http-method>
<http-method>TRACE</http-method>
<http-method>OPTIONS</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>

<role-name>role1</role-name>
</auth-constraint>
</security-constraint>

<security-role>

<role-name>role1</role-name>
</security-role>

</web-app>

when i am trying to run the jsp page on server getting


HTTP Status 403 - Access to the requested resource has been denied

how can i associate the role with the request .do i need to do any extra configuration ?Please help.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

what kind of auth-method you are using ? and where do you put your authentication detail; for instance if you use tomcat then user details will be in tomcat-users.xml
Deep Mukherjee
Greenhorn

Joined: Jan 04, 2010
Posts: 20
I am using Basic authentication for tomcat and added the role in tomcat-user.xml
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: problem on validatinfg role for security of </security-constraint>
 
Similar Threads
Authentication and Authorization implementation using DD Problem
he doesn't ask for authenticate
problems with form-based authentication
Can't display web app security
Problem with Form-based Authentication ...