这好像是ASP中的使用吧。ContentType 属性
ContentType 属性指定响应的 HTTP 内容类型。如果未指定 ContentType,默认为 text/HTML语法
Response.ContentType [= ContentType]
参数
ContentType
描述内容类型的字符串。该字符串通常被格式化为类型/子类型,其中类型是常规内容范畴而子类为特定内容类型。有关支持内容类型的完整列表,请参阅 Web 浏览器文档或当前的 HTTP 规格说明。
示例
下面的示例将内容类型设置为 Channel Definition Format(CDF)。<% Response.ContentType = "application/x-cdf" %>
下面的示例将 ContentType 属性设置为其他的常见值。<% Response.ContentType = "text/HTML" %>
<% Response.ContentType = "image/GIF" %>
<% Response.ContentType = "image/JPEG" %>
应用于
Response 对象
ContentType 属性指定响应的 HTTP 内容类型。如果未指定 ContentType,默认为 text/HTML语法
Response.ContentType [= ContentType]
参数
ContentType
描述内容类型的字符串。该字符串通常被格式化为类型/子类型,其中类型是常规内容范畴而子类为特定内容类型。有关支持内容类型的完整列表,请参阅 Web 浏览器文档或当前的 HTTP 规格说明。
示例
下面的示例将内容类型设置为 Channel Definition Format(CDF)。<% Response.ContentType = "application/x-cdf" %>
下面的示例将 ContentType 属性设置为其他的常见值。<% Response.ContentType = "text/HTML" %>
<% Response.ContentType = "image/GIF" %>
<% Response.ContentType = "image/JPEG" %>
应用于
Response 对象
Response.ClearHeaders ();
Response.ContentType ="application/pdf";
Response.WriteFile("Exports/account.pdf");
Response.Flush();
Response.Close();
<input type="radio" name="choice" value="1">HTML<br>
<input type="radio" name="choice" value="2">gif<br>
<input type="radio" name="choice" value="3">pdf<br>
<input type="submit" name="ok" >
</form><%
String aaa=request.getParameter("choice");
if(aaa.equals("1")){
Response.ContentType = "text/HTML"
}else if(aaa.equals("2")){
Response.ContentType = "image/GIF"
}else if(aaa.equals("3")){
Response.ContentType = "application/x-cdf"
}
%>
res.setHeader("Content-Disposition",
"attachment; filename=idc_xn_printlist.doc");
Dispatcher("/*.jsp").forward(req, res);
if("1".equals(type)) filename="LISTOLDHGZ.jasper";
else filename="listcsb.jasper";
File reportFile = new File(application.getRealPath("report/"+filename));
Map parameters = new HashMap();
parameters.put("HH", usercode);
parameters.put("HGZFL", hgzfl);
parameters.put("YWLX",ywlx);
Connection conn=null; Jdbc jdbc=new Jdbc();
conn=jdbc.conn;
try{
//System.out.println("111");
System.out.print("size="+ parameters.size());
byte[] bytes =
JasperRunManager.runReportToPdf(
reportFile.getPath(),
parameters,
conn
);//System.out.print("222"); response.setContentType("application/pdf"); response.setContentLength(bytes.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.flush(); ouputStream.close();
//jdbc.exec("update g_hgz set hgzdyrq=sysdate where czydm='"+usercode+"'");}