/ * * Created on 2004-12-24 * * Todo to change the Template for this generated file go to * window - preferences - java - code style - code templates * / package com.util;
Import java.io. *; import javax.servlet. *; import javax.servlet.http. *; import com.jspsmart.upload. *; import com.util.stringutIL;
/ ** * @author richard * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates * / public class DownCultureFile extends HttpServlet {
private ServletConfig config; / ** * * / public DownCultureFile () {super (); // TODO Auto-generated constructor stub} public void init (ServletConfig config) throws ServletException {this.config = config;} public void service (HttpServletRequest Request, httpservletresponse response) throws servletexception, ioException {
String fileName = request.getParameter ( "fileName"); PrintWriter out = response.getWriter (); ServletContext context = config.getServletContext (); SmartUpload su = new SmartUpload (); // initialize try {su.initialize (config, request , response); su.setContentDisposition (null); String strFileName = "// culturepic //" fileName; strFileName = context.getRealPath (strFileName); //su.downloadFile(strFileName,"",fileName); su.downloadFile (StrfileName, "", "} Catch (Exception E) {Out.println (" Unable to Download the file.
"); Out.println (" Error: " E.TOString () );} su = null;} / * public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doGet (request, response);} * / private String toUtf8String (String s) throws UnsupportedEncodingException {StringBuffer sb = new StringBuffer (); For (int i = 0; i