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
<