jsp file stream download page

2011-01-07  来源:本站原创  分类:Java  人气:103 

Download my own use interface, you need to use a simple modification. Keep some file stream functions can be

<% @ Page language = "java" import = "com.casw.pioagis.util.domain.Domain" pageEncoding = "utf-8"%>
String path = this.getServletContext (). GetRealPath ("importFiles");
String filename = request.getParameter ("fileName");

/ / Key on = key: [table name. Xls] value: [Chinese name. Xls]
/ / Add a file to download each will add a map

Domain domain = new Domain ();
String filerealname = domain.getCodeName ("uploadModelType", filename). ToString ();

String filenamecn = filerealname + ". Xls";

String filePath = path + "/ /" + filenamecn;
java.io.FileInputStream bis = null;
java.io.OutputStream bos = null;

response.setCharacterEncoding ("iso8859-1");
response.setContentType ("application / unknown");
response.addHeader ("Content-Disposition", "attachment; filename = \" "+ new String (filenamecn.getBytes (" gb2312 ")," iso8859-1 "));
/ / String filePath = path +"//"+ fileName;
bis = new java.io.FileInputStream (filePath);
bos = response.getOutputStream ();
byte [] buff = new byte [2048];
int bytesRead;
while (-1! = (bytesRead = bis.read (buff, 0, buff.length)))
bos.write (buff, 0, bytesRead);
} Catch (Exception e)


<script type="text/javascript">
alert ('system can not find the file');
</ Script>
e.printStackTrace ();
if (bis! = null) {
bis.close ();
out.clear ();
out = pageContext.pushBody ();

  • jsp file stream download page 2011-01-07

    Download my own use interface, you need to use a simple modification. Keep some file stream functions can be <% @ Page language = "java" import = "com.casw.pioagis.util.domain.Domain" pageEncoding = "utf-8"%> <% Stri

  • jsp file to download to achieve 2010-04-06

    jsp file to download to achieve the most simple way is to make hyperlinks on the page, such as: <a href="music/abc.mp3"> Click to download </ a>. But this directory on the server resources will be directly exposed to the end user, wi

  • Jsp file name support Chinese download (Fixed BUG Edition) 2011-05-17

    down.jsp code: <% @ Page contentType = "text / html; charset = gbk"%> <% @ Page language = "java" import = "java.io. *, java.net .*" pageEncoding = "gbk"%> <html> <head> <title> test &l

  • struts + spring + hibernate integration of several small issues (dynamically generated excel file and download) 2010-09-06

    When spring struts integration, see the configuration of the following action: <bean scope="prototype"> <property name="service" ref="userService"></property> </bean> The default scope is singleton, if

  • encoding encoding problems two Jsp file 2010-05-08

    5.jsp editing, uploading, compiled into servlet, network transmission what happened? Edit] [jsp file when you save the default windows operating development is in accordance with GBK encoding of the string, you can specify the save as UTF-8 and other

  • Javaweb (6) JSP File Upload 2010-08-26

    Upload file examples are <%@ page contentType="text/html;charset=GB2312" %> <HTML> <head> <title> Upload file example </title> </head> <BODY> Upload file program application example <FORM action="

  • JSP file operations file creation / check and delete 2010-09-06

    JSP file operations Daquan instance document creation / check and delete <% @ Page contentType = "text / html; charset = gb2312"%> <% @ Page import = "java.io. *"%> <html> <head> <title> documents to estab

  • struts2 file upload / download / garbled stop the annoying chatters 2010-11-19

    My environment English windows xp location: United states language for non-Unicode program: Chinese (PRC) tomcat 6.0 struts2-core-2.2.1 Online on the struts file upload / download the article a lot of mines. In my environment, only then spent a week

  • To change the JSP file suffix 2010-08-02

    Today nothing else to do, suddenly thought of a problem, can not access JSP files to my own suffix suffix replaced it? Through some of their own debugging, finally succeeded friends. Ha ha ha. So happy ..... First, WEB.XM in configuration <servlet>

  • [DWR] asynchronous request file to download is IE's MessageBar intercept solutions 2010-08-18

    Download the project is DWR3.0 above file download to achieve, because it is more flexible, but also by defining the Servlet to bypass the file download to support trouble-value problem (avoid using Cache). In dwr's engine.js which have dwr.engine.op

  • jsp file using the character set issues include 2010-09-12

    Used in a login.jsp <% @ Page contentType = "text / html; charset = GBK"%> <% @ Include file = "top.jsp"%> But also with the GBK top.jsp But always error: Page directive: illegal to have multiple occurrences of contentType

  • jsp source code download photo 2010-06-20

    jsp source code download pictures. jsp source code of the camera. jsp camera programming. jsp camera. Camera photo program.

  • MyEclipse5.0 can not open the JSP file 2010-08-24

    MyEclipse JSP file can not open the question MyEclipse5.0 for Eclipse3.2 installation can not create a JSP file, and also can not open an existing JSP file, MyEclipse5.0 not open jsp The solution: the following information: An error has occurred.See

  • Scanner programming examples jsp source code download 2010-10-31

    jsp programming scanner jsp source code download scanner jsp source code of the scanned image jsp source code download scanner program web programming control sample was scanned images download

  • The C version of the file stream operations 2010-12-02

    Lately because the school's curriculum, always encountered file operation, although already be learned, and can still feel it every time with a solid enough, ah, come across some problems still have to open book depressing, is feeling very uncomforta

  • File stream operations of C + + Edition 2010-12-03

    Yesterday, a brief introduction about C file stream operations, in fact, more powerful, more complex operations have to see C + +, after all, C + + is a C, to strengthen, both from the functionality and efficiency than the C higher than a grade, and

  • Mid-stream on the use of Delphi (2) TFileStream (file stream) to read and write 2011-01-09

    TStream is an abstract base class, can not directly generate object. In specific applications, mainly using its descendant classes: TFileStream: file stream TStringStream: string stream TMemoryStream: memory stream TResourceStream: resource file stre

  • jsp file upload control to achieve the application code examples 2011-04-30

    html <html> <head> <title> uploading files </ title> </ Head> <body> <form action="basic.jsp Tutorial " method="post"> <input type="file" name="filer"> <br> <

  • jsp file is too large to compile the generated java file can not be the problem 2011-10-22

    jsp file is too large to compile the generated java file can not be the problem See, for example http://lucene3211.iteye.com/blog/1150951 with Can solve this problem using dynamic includes. org.apache.jasper.JasperException: Unable to compile class f

  • Response Stream Download File 2010-03-29

    Recent studies of the documents are now the code is as follows: protected void doGet (HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ( String templateName = req.getParameter ( "templateName ");// need down