Getting the Linux version and distribution that you are using

Sometimes, you may not have the information of the Linux server that you are deploying your applications on. In order to get the Linux version and distribution, all what you need to do is to use the cat command as follows:

cat /etc/*-release

The distribution and version information are stored in the /etc directory with the pattern *-release.

java.net.SocketTimeoutException: Socket operation timed out before it could be completed

You may face this exception in the log file of your web application:

java.net.SocketTimeoutException: Socket operation timed out before it could be completed

After investigating in the error, I found that it happens because of the network connectivity. I could fix it by fixing the network cable.

Getting the path of WEB-INF folder from a Java Servlet

You may need to get the path of the WEB-INF folder from your Java Servlet for reading custom configuration files or writing temporary files or doing other related work. In order to get the path of the WEB-INF folder (or its sub folders) from your Java Servlet service methods, you can do this by using the getRealPath() API in the ServletContext interface as follows:

String path = getServletContext().getRealPath("/WEB-INF");

If we have for example a folder called xyz under the WEB-INF folder, we can get its path as follows:

String path = getServletContext().getRealPath("/WEB-INF/xyz");

Error 500: java.lang.NoClassDefFoundError: org.apache.commons.io.output.DeferredFileOutputStream

You may face this error when you are working with Apache commons file upload.

Error 500: java.lang.NoClassDefFoundError: org.apache.commons.io.output.DeferredFileOutputStream

In order to solve this error, you need to include the Apache commons IO jar in the lib folder of your web application. You can download this jar from: http://commons.apache.org/io/download_io.cgi.