Reputation:
I already have two filters, which typically checks for a valid session. If session is valid it'll redirect to the ExpenseDetailsManagement.html
else ExpenseManagementLogin.html
. The web.xml config looks like
<filter>
<filter-name>ExpenseAuthentication</filter-name>
<filter-class>com.pricar.hibernate.ExpenseAuthentication</filter-class>
</filter>
<filter>
<filter-name>ExpenseAuthenticationFilter</filter-name>
<filter-class>com.pricar.hibernate.ExpenseAuthenticationFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ExpenseAuthentication</filter-name>
<url-pattern>*/ExpenseDetailsManagement.html</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>ExpenseAuthenticationFilter</filter-name>
<url-pattern>*/ExpenseManagementLogin.html</url-pattern>
</filter-mapping>
The above two were working fine.
The application path looks like
http://localhost:8080/Hibernate/ExpenseManagementLogin.html
If I try with http://localhost:8080/Hibernate
, then ExpenseManagementLogin.html
is loading
even if I have a valid session.
For that I tried some url-mapping-patterns like Hibernate/
, /Hibernate/
, /*
then
it ends with infinite looping or resource not found error.
My web-app just have two HTML pages, one for login and another for app-stuff.
Any suggestions?
Upvotes: 1
Views: 1177
Reputation: 10373
Why do you use two filters?
Remove ExpenseAuthentificationFilter
. In the simplest case, place the ExpenseManagementLogin.html file in the root of the war.
Add a Servlet or a JSP as the login form target.
Configure the page ExpenseDetailsManagement.html as the default page.
Then the following scenario is possible:
http://localhost:8080/Hibernate
http://localhost:8080/Hibernate/ExpenseDetailsManagement.html
http://localhost:8080/Hibernate/ExpenseManagementLogin.html
, if no valid session is active.http://localhost:8080/Hibernate/ExpenseDetailsManagement.html
.You can also use JAAS to handle login and authentification.
Upvotes: 1