File Upload using struts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raagadeepthi
    New Member
    • Sep 2009
    • 19

    File Upload using struts

    Iam trying to upload file using struts but getting "file not found exception" please suggest!!! below is the code

    public ActionForward execute(ActionM apping mapping, ActionForm form, HttpServletRequ est request, HttpServletResp onse response)
    {
    response.setCon tentType("text/html;charset=UT F-8");
    PrintWriter out;
    try {
    out = response.getWri ter();
    } catch (IOException ex) {
    ex.printStackTr ace();
    }
    UploadFileForm uff=(UploadFile Form)form;
    readExcel xlReader = new readExcel();
    FormFile myfile= null;
    FileInputStream fs=null;
    try {
    myfile=uff.getT heFile();
    System.out.prin tln(myfile.getF ileName());
    String path = getServlet().ge tServletContext ().getRealPath( "")+"/"+myfile.getFil eName();

    fs = new FileInputStream (new File(path));
    contentReading( fs);
    } catch (FileNotFoundEx ception ex) {
    ex.printStackTr ace();
    } catch (Exception e){
    e.printStackTra ce();
    }
  • raagadeepthi
    New Member
    • Sep 2009
    • 19

    #2
    Can someone please help

    Comment

    Working...