To the point, here are some of my files:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://ift.tt/ra1lAU"
xmlns="http://ift.tt/nSRXKP"
xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/1eWqHMP"
id="WebApp_ID" version="3.0">
<display-name>Fix My Home</display-name>
<!-- <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> -->
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/error.jsp</form-error-page>
</form-login-config>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>fixmyhome</web-resource-name>
<url-pattern>/main.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>*</role-name>
</auth-constraint>
<user-data-constraint>
<transport-guarantee>NONE</transport-guarantee>
</user-data-constraint>
</security-constraint>
<security-role>
<role-name>*</role-name>
</security-role>
<servlet>
<servlet-name>SecurityServlet</servlet-name>
<servlet-class>com.jaas.security.servlet.SecurityServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SecurityServlet</servlet-name>
<url-pattern>/SecurityServlet</url-pattern>
</servlet-mapping>login.jsp
<head>
<title>Fix My Home</title>
</head>
<body>
<form method="post" action="./SecurityServlet">
User ID: <INPUT type="text" name="j_username" /> <br /> Password : <INPUT
type="password" name="j_password" /> <br /> <INPUT type="submit"
value="Submit" />
</form>
</body>
Here's the issue (my context is fixmyhome)
a) with URL pattern "/main.jsp"
1. Using http://localhost:8080/fixmyhome/main.jsp, the servlet SecurityServlet gets invoked.
2. Using http://localhost:8080/fixmyhome/, servlet SecurityServlet not invoked
b) with URL pattern "/"
Using http://localhost:8080/fixmyhome/, servlet SecurityServlet not invoked. Why? I expect the login.jsp action="./ServletSecurity" will get this servlet invoked.
Important note:
The "/" indicates default servlet but this is not servlet mapping. The URL pattern is in the web-collection and not servlet-mapping element.
Aucun commentaire:
Enregistrer un commentaire