How to pass System Properties in web.xml

In Java standalone application, you can use -D option to pass in the system properties : $ java -Dgeoip.file="/home/mkyong/geoip/test.db" test.jar In Java web application, you can pass the system properties via context-param in web.xml : web.xml <web-app> <context-param> <param-name>geoip.file</param-name> <param-value>/home/mkyong/geoip/test.db</param-value> </context-param> </web-app>

web.xml deployment descriptor examples

The web.xml is a configuration file to describe how a web application should be deployed. Here’re 5 web.xml examples, just for self-reference. 1. Servlet 3.1 deployment descriptor Java EE 7 XML schema, namespace is http://xmlns.jcp.org/xml/ns/javaee/ web.xml <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> </web-app> 2. Servlet 3.0 deployment descriptor Java EE 6 XML schema, namespace is …

Read more

How to prevent others steal your web image (hotlinking)

My website’s images are kept directly link (hotlinking) by other websites, it’s a thief behavior and eating my bandwidth, why don’t they copy to their own server and display it? I decided to take action to stop this happened again, this so called “hotlinking” can be stopped by “.htaccess” access control. Case Study 1. Hotlinking …

Read more

svn+ssh hit Connection closed unexpectedly error in Eclipse – (Solution)

Latest Eclipse IDE is required to support the hibernate tools plug-in. However my “svn+ssh” is not working correctly after updated to the latest Eclipse IDE and Subeclipse version of 1.6.x. While i initial the “svn+ssh” access connection in Eclipse IDE, i had encountered the following error message. Network connection closed unexpectedly svn: Connection closed unexpectedly …

Read more

How to get context-param value in java?

The “context-param” tag is define in “web.xml” file and it provides parameters to the entire web application. For example, store administrator’s email address in “context-param” parameter to send errors notification from our web application. web.xml <context-param> <param-name>AdministratorEmail</param-name> <param-value>[email protected]</param-value> </context-param> We can get the above “AdministratorEmail” context-param value with the following java code. String email= getServletContext().getInitParameter("AdministratorEmail"); …

Read more