Available since OmniFaces 1.2

This configuration interface parses the /WEB-INF/web.xml and all /META-INF/web-fragment files found in the classpath and offers methods to obtain information from them which is not available by the standard Servlet API.


Some examples:

// Get the <welcome-file-list> (which are essentially path-relative filenames which needs to be served when a folder is requested).
List<String> welcomeFiles = WebXml.instance().getWelcomeFiles();
// Get a mapping of all error page locations by exception type (a key of null represents the default error page location, if any).
Map<Class<Throwable>, String> errorPageLocations = WebXml.instance().getErrorPageLocations();
// Get the <form-login-page> (which is a context-relative URL to the login page of FORM based authentication).
String formLoginPage = WebXml.instance().getFormLoginPage();
// Get a mapping of all <security-constraint> URL patterns and associated roles.
Map<String, Set<String>> securityConstraints = WebXml.instance().getSecurityConstraints();
// Check if access to certain (context-relative) URL is allowed for the given role based on <security-constraint>.
boolean accessAllowed = WebXml.instance().isAccessAllowed("/admin.xhtml", "admin");
// Get web.xml configured session timeout (in seconds).
int sessionTimeout = WebXml.instance().getSessionTimeout();

Feature request

If you know more useful methods/functions which you think should be added to this OmniFaces utility class so that everyone can benefit from a "standard" JSF utility library, feel free to post a feature request.

Documentation & Sources

API documentation

Java source code