Tuesday, September 19, 2017

Tomcat: Application session timeout


To set the session timeout for the Tomcat web application, call HttpSession.setMaxInactiveInterval(int interval) -- interval is the idle time in seconds before timeout. e.g. HttpSession.setMaxInactiveInterval(30) times out the session if it is idle more than 30 seconds.

If the above method is not call in the application, the session-timeout configuration in the application's web.xml defines the timeout in minutes. e.g. WEB-INF/web.xml:
    <session-config>
          <session-timeout>1</session-timeout>
    </session-config>
The above configuration times out the session after 1 minute.

If the session-timeout is not set in the application's web.xml, it is defined in TOMCAT_HOME/conf/web.xml:
    <session-config>
          <session-timeout>30</session-timeout>
    </session-config>

Sunday, September 10, 2017

JSP: escape XML


In JSP:

<%@ taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<% String str = "<abc &  ' \">"; %>

<html>
<body>

<p>Escaped string: <%= fn:escapeXml(str) %> </p>

</body>
</html>
 

This requires the JSTL 1.2 JAR, which can be downloaded at https://mvnrepository.com/artifact/javax.servlet/jstl/1.2



Sunday, August 27, 2017

Windows 10 Disk Usage 100% - Disable Microsoft Compatibility Telemetry


To find out why the Disk Usage is constantly at 100%:

1. Start the Task Manager: Right click on the toolbar and select Task Manager.
2. Click the Processes tab.
3. Click on the Disk column to sort the Disk Usage in descend order.
4. Right click on the header (Disk) and select Resource Values -> Disk -> Percents
5. Find out which process has the highest percentage of Disk Usage.

If Microsoft Compatibility Telemetry is always the No 1 process, we can disable it as below:

1. Right click the Windows Start icon and select Command Prompt (Admin) to open a command line window with the Administrator permission.
2. Run command taskschd.msc to start the Task Scheduler.
3. On the left panel, select Microsoft -> Windows -> Application Experience
4. On the middle top panel, find Microsoft Compatibility Appraiser.
5. Right click on Microsoft Compatibility Appraiser and select Disable.
 
Get This <