Jspsmartupload download implementation

Source: Internet
Author: User
Tags file upload

 

The down.html code is as follows: the principle is to use a hyperlink to a jsp to call the downloaded code through jsp.



<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Title> File upload </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>
<Body>
<P align = "center">
Upload file selection
</P>
<Form method = "POST" ACTION = "up. jsp" ENCTYPE = "multipart/form-data">
<Input type = "hidden" name = "TEST" value = "good">
<Table width = "75%" border = "1" align = "center">
<Tr>
<Td>
<Div align = "center">
1,
<Input type = "FILE" name = "FILE1" size = "30">
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Div align = "center">
2,
<Input type = "FILE" name = "FILE2" size = "30">
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Div align = "center">
3,
<Input type = "FILE" name = "FILE3" size = "30">
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Div align = "center">
4,
<Input type = "FILE" name = "FILE4" size = "30">
</Div>
</Td>
</Tr>
<Tr>
<Td>
<Div align = "center">
<Input type = "submit" name = "Submit" value = "upload it! ">
</Div>
</Td>
</Tr>
</Table>
<Br>
<Br>
<A href = "down. jsp"> Click to download </a>
</FORM>
</Body>
</Html>

Down. jsp

 



<%... @ Page contentType = "text/html; charset = gb2312" language = "java" import = "java. util. *, com. jspsmart. upload. *, java. lang. * "errorPage =" "%>

<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>

<Title> My JSP ''down. jsp ''' starting page </title>

</Head>
  
<Body>
<%... SmartUpload su = new SmartUpload ();
Su. initialize (pageContext );
Su. setContentDisposition (null); // whether to enable it automatically. If it is null, it cannot be enabled automatically.
Su. downloadFile ("c: Producer. cer ");
Out. clear ();
Out = pageContext. pushBody ();
%>
</Body>
</Html>

The following two sentences are worth mentioning: <%>

Out. clear ();
Out = pageContext. pushBody ();
Be sure to add it. Otherwise, an exception will be reported: getOutputStream () has already been called for this response

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.