Archive for the ‘Tomcat’ Category

Tomcat: remote debugging setup

Friday, November 20th, 2009
set JPDA_ADDRESS=8000
set JPDA_TRANSPORT=dt_socket
bin/catalina.bat jpda start

Source

Java: Servlet Set Expires Header with Cache Control

Saturday, March 28th, 2009

When setting the expires date in Servlet, better to set the cache-control as well.

final int CACHE_DURATION_IN_SECOND = 60 * 60 * 24 * 2; // 2 days
final long   CACHE_DURATION_IN_MS = CACHE_DURATION_IN_SECOND  * 1000;
long now = System.currentTimeMillis();
//res being the HttpServletResponse of the request
res.addHeader("Cache-Control", "max-age=" + CACHE_DURATION_IN_SECOND);
res.addHeader("Cache-Control", "must-revalidate");//optional
res.setDateHeader("Last-Modified", now);
res.setDateHeader("Expires", now + CACHE_DURATION_IN_MS);

For no cache

res.setHeader("Pragma", "No-cache");
res.setHeader("Cache-Control", "no-cache,no-store,max-age=0");
res.setDateHeader("Expires", 1);

Tomcat: Virtual Hosting and Web App

Sunday, November 2nd, 2008

To map a domain name to a “war” web application.

File: [tomcat-path]/conf/server.xml

<Service>….
<Service>….
<Engine>…

<Host name=”www.yourdomain.com” appBase=”webapps/webappname”
unpackWARs=”true” autoDeploy=”true”
xmlValidation=”false” xmlNamespaceAware=”false”>
<Context path=”" docBase=”.”/>
<Alias>yourdomain.com</Alias>
</Host>

</Engine>
</Service>
</Server>
Note: This obviously assumes that this domain name is mapped to the specific tomcat instance.