0

I have created a filter login How to redirect a logged out user to the home page in Java EE/JSF?

But now I want to set just some specific pages have to login. I created some pages and put them into private folder, and changed the filter's url like this

<filter-name>AuthenticationLogin</filter-name>
    <filter-class>filter.AuthenticationLogin</filter-class>
</filter>
<filter-mapping>
    <filter-name>AuthenticationLogin</filter-name>
    <url-pattern>/private/*</url-pattern>
</filter-mapping>

It doesn't work :(

Any suggestion. Thanks in advance.

Community
  • 1
  • 1
qangdev
  • 336
  • 5
  • 15
  • Your filter mapping is correct. "It doesn't work" is not correct problem description. Can you put breakpoint in `doFilter` method of filter and check what happens when you go to on private page (/private/pagename)? Try use following redirection `response.sendRedirect(request.getContextPath() + "/login.jsf");` – Vasil Lukach Jun 25 '14 at 18:33
  • It works perfectly!Thank you! I am a begginer in JSF. – qangdev Jul 01 '14 at 02:10

1 Answers1

0

Your filter mapping is correct. You can use following redirection

response.sendRedirect(request.getContextPath() + "/login.jsf");

in filter.

Vasil Lukach
  • 3,658
  • 3
  • 31
  • 40