The simplest way is with Filter. With the filter, which is already from java, you can intercept the request and validate whether a particular user is active or not.
With the filter you can determine which folder/file the user can access logged in or not.
Here is an example: http://uaihebert.com/? p=1414
So you could set up a filter on the web.xml:
<filter>
<filter-name>AdminPagesFilter</filter-name>
<filter-class>com.filter.AdminPagesFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AdminPagesFilter</filter-name>
<url-pattern>/pages/protected/admin/*</url-pattern>
</filter-mapping>
And a filter could be declared as:
public class AdminPagesFilter extends AbstractFilter implements Filter {
@Override
public void destroy() {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
User user = (User) req.getSession(true).getAttribute("user");
if (!user.isAdmin()) {
accessDenied(request, response, req);
return;
}
chain.doFilter(request, response);
}
@Override
public void init(FilterConfig arg0) throws ServletException {
}
}
Add more content to your reply. Usually responses containing only links are not very well seen, after all, if the site goes off the air the answer becomes useless, in addition to being in another language.
– Filipe.Fonseca