Why use a JSF ExceptionHandlerFactory instead of redirection?

The particular example does only one useful thing: it saves the view ID as a request attribute so that you can use for example <h:link value=”Go back to previous page” outcome=”#{currentViewId}” /> But this is not tremendously useful as the raw request URI is already available by the <error-page>‘s default request attribute javax.servlet.error.request_uri. <h:outputLink value=”#{requestScope[‘javax.servlet.error.request_uri’]}”>Go … Read more

Maven: Customize web.xml of web-app project

is there a way to have two web.xml files and select the appropriate one depending on the profile? Yes, within each profile you can add a configuration of the maven-war-plugin and configure each to point at a different web.xml. <profiles> <profile> <id>profile1</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webXml>/path/to/webXml1</webXml> </configuration> </plugin> … As an alternative … Read more

Why do we use web.xml? [closed]

Generally speaking, this is the configuration file of web applications in java. It instructs the servlet container (tomcat for ex.) which classes to load, what parameters to set in the context, and how to intercept requests coming from browsers. There you specify: what servlets (and filters) you want to use and what URLs you want … Read more

Spring application context : access web.xml context-params?

Yes – ServletContextPropertyPlaceholderConfigurer This article explains the details. In short, you need: <bean class=”org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer”> </bean> and then use the properties like: <bean …> <property name=”compassIndex” value=”${compass-index}” /> </bean> or with @Value(“${compass-index}”)

How to exclude one url from authorization

Omit the <auth-constraint> element in <security-constraint> for resources for which you don’t need authentication like: <security-constraint> <web-resource-collection> <web-resource-name>app</web-resource-name> <url-pattern>/info</url-pattern> </web-resource-collection> <!– OMIT auth-constraint –> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>app</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>Role</role-name> </auth-constraint> </security-constraint>

Session TimeOut in web.xml

To set a session-timeout that never expires is not desirable because you would be reliable on the user to push the logout-button every time he’s finished to prevent your server of too much load (depending on the amount of users and the hardware). Additionaly there are some security issues you might run into you would … Read more

How to include values from .properties file into web.xml?

You can add this class, that add all properties from your file to JVM. And add this class like context-listener to web.xml public class InitVariables implements ServletContextListener { @Override public void contextDestroyed(final ServletContextEvent event) { } @Override public void contextInitialized(final ServletContextEvent event) { final String props = “/file.properties”; final Properties propsFromFile = new Properties(); try … Read more

Whitelist security constraint in web.xml

I would try the following: <security-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <!– no auth-constraint tag here –> </security-constraint> <security-constraint> <web-resource-collection> <web-resource-name>restricted methods</web-resource-name> <url-pattern>/*</url-pattern> </web-resource-collection> <auth-constraint/> </security-constraint> The first security-constraint does not have any auth-constraint, so the GET and POST methods are available to anyone without login. The second restricts other http methods for everybody. (I … Read more

AngularJS HTML5 Mode – How do direct links work without server specific changes?

The AngularJS documentation does in fact mention this Server side Using this mode requires URL rewriting on server side, basically you have to rewrite all your links to entry point of your application (e.g. index.html) In this case, one Java-based solution is to tell the server “map all urls to index.html.” This can be done … Read more