« XML parsing in JavaScript | Main | Best of current trends in web-design »

January 26, 2006

HTTP headers beyond Content-Type in JSP/JSTL

Use setHeader before the contentType statement:

<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setHeader("Content-disposition","attachment; filename=annual_finance_report.csv"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

<%@ page contentType="application/vnd.ms-excel"%>

Though you can't do CSV in JSTL because of whitespace issues.

Tags: JSP

Posted by pj at January 26, 2006 03:19 PM