String filename=this.servlet.getServletContext().getRealPath("/");
FileOutputStream fos = new FileOutputStream
                         (filename+"/java/Tomcat 5.0/webapps/SExam/files/" 
                         + fileUp.getFileName());)

解决方案 »

  1.   

    在一般Servlet里用this.getServletContext().getRealPath("/upload"); upload为工程的一个文件夹;
    在struts action中this.getServlet().getServletContext().getRealPath("/upload");
      

  2.   

    FormFile file = ...Form.getFile();
    InputStream is = file.getInputStream();
    FileOutputStream fos = new FileOutputStream(this.getServletContext().getRealPath("/upload"));
    int x;
    while((x=is.read())!=-1){
        fos.write(x);
    }
    fos.flush();
    fos.close();