難題_高分吐血求助servlet高手幫忙
各位高手大大:
我有一個在線打開excel,word...的OpenFile servlet,代碼如下:
---------------------------------
package pursue.com.web;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import pursue.com.util.Globals;
public class Openfile
extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=UTF-8 ";
private String errMsg = "uploadMsg ";
//Initialize global variables
public void init() throws
ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
HttpSession session = request.getSession();
String filename = request.getParameter( "file_name ");
filename = Globals.RTC_UP_PATH + "/ " + filename;
response.setHeader( "Content-disposition ",
"attachment;filename= " +
filename.replace( '\\ ', '/ ').
substring(filename.lastIndexOf( "/ ")));
String ext=filename.substring(filename.lastIndexOf( ". ")+1);
if(ext.equalsIgnoreCase( "xls ")){
System.out.println( "xlsfile: "+filename);
response.setContentType( "application/vnd.ms-excel ");
}else{
System.out.println( "html: "+filename);
response.setContentType( "text/html ")