ÓÃJSPÏÂÔØwordÎļþ
<%@page import="java.util.*"%>
<%@page import="java.io.*"%>
<%@page import="java.net.*"%>
<%
String filename = "";
if (request.getParameter("file") != null) {
filename = request.getParameter("file");
}
response.setContentType("application/msword");
response.setHeader("Content-disposition","attachment; filename="+filename);
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath("" + filename)));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff,0,bytesRead);
}
} catch(final IOException e) {
System.out.println ( "³öÏÖIOException." + e );
} finally {
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
return;
%>
Ïêϸ³ö´¦²Î¿¼£ºhttp://www.jb51.net/article/2631.htm
Ïà¹ØÎĵµ£º
JSP/Servletת·¢ÓëÖض¨ÏòµÄÇø±ð
¾¡¹ÜHttpServletResponse.sendRedirect ·½·¨ºÍRequestDispatcher.forward ·½·¨¶¼¿ÉÒÔÈÃä¯ÀÀÆ÷»ñµÃÁíÍâÒ»¸öURLËùÖ¸ÏòµÄ×ÊÔ´£¬µ«Á½ÕßµÄÄÚ²¿ÔËÐлúÖÆÓÐןܴóµÄÇø±ð¡£
¡¡¡¡ÏÂÃæÊÇHttpServletResponse.sendRedirect ·½·¨ÊµÏÖµÄÇëÇóÖض¨ÏòÓëRequestDispatcher.forward ·½·¨ÊµÏÖµÄÇëÇó ......
Ñ¡ÌâÒÀ¾Ý¼°Ñо¿ÒâÒå
ÏÖ´úÎïÁ÷£¬ÊÇÖ¸²úÆ·´ÓÉú²úµØµ½Ïû·ÑµØÖ®¼äµÄÕû¸ö¹©Ó¦Á´£¬ÔËÓÃÏȽøµÄ×éÖ¯·½Ê½ºÍ¹ÜÀí¼¼Êõ£¬½øÐиßЧÂʼƻ®¡¢¹ÜÀí¡¢ÅäËÍÁ´£¬ÎªÓû§Ìṩ¶à¹¦ÄÜ¡¢Ò»Ì廯µÄ×ÛºÏÐÔ·þÎñ£¬´Ó¶ø´ïµ½½µµÍÁ÷ͨ³É±¾¡¢Ìá¸ßÉú²úЧÂÊ¡¢Ôö¼ÓÆóÒµÀûÈó¡£µÄÐÂÐÍ·þÎñÒµ¡£Ëüͨ¹ý¶ÔÔËÊä¡¢²Ö´¢¡¢×°Ð¶¡¢¼Ó¹¤¡¢ÕûÀí¡¢ÅäËÍÓëÐÅÏ¢µÈ·½ÃæÓлú½áºÏ£¬ÐÎ ......
ÑéÖ¤ÂëµÄÉú³É˼ÏëÊÇÔÚ·þÎñÆ÷¶ÎÔ¤ÏÈÉú³ÉºÃÑéÖ¤Â룬ǰ̨ÏÔʾ£¬È»ºóÔÙµ½ºǫ́ȥƥÅ䣡
code.jsp:
<%@ page language="java" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*"
contentType="image/jpeg" pageEncoding="UTF-8"%>
<% //ÉèÖÃÒ³Ãæ²»» ......
<%@ page autoFlush="false" contentType="text/html;charset=utf-8" language="java" import="java.io.*,java.awt.Image,java.awt.image.*,com.sun.image.codec.jpeg.*,java.sql.*,com.jspsmart.upload.*,java.util.*,java.io.FileInputStream,java.io.FileOutputStream,java.awt.*"%>
<%@ page import="com.b ......