1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to upload the Files with JSf and Myfaces

Discussion in 'JSP' started by Goutham, Jan 4, 2007.

  1. Goutham

    Goutham New Member

    Joined:
    Jan 4, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hi ,

    i have used
    Code:
         <filter-mapping>
              <filter-name>extensionsFilter</filter-name>
            <url-pattern>*.jsf</url-pattern>
            </filter-mapping>
         <filter-mapping>
            <filter-name>extensionsFilter</filter-name>
            <url-pattern>/faces/*</url-pattern>
         </filter-mapping>
    
    in web.xml file

    Bean class
    Code:
    public class FileUploadForm
    {
        private UploadedFile _upFile;
        private String _name = "";
    
        public UploadedFile getUpFile()
        {
            return _upFile;
        }
    
        public void setUpFile(UploadedFile upFile)
        {
            _upFile = upFile;
        }
    
        public String getName()
        {
            return _name;
        }
    
        public void setName(String name)
        {
            _name = name;
        }
    
        public String upload() throws IOException
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            facesContext.getExternalContext().getApplicationMap().put
    ("fileupload_bytes", _upFile.getBytes());
            facesContext.getExternalContext().getApplicationMap().put
    ("fileupload_type", _upFile.getContentType());
            facesContext.getExternalContext().getApplicationMap().put
    ("fileupload_name", _upFile.getName());
            return "ok";
        }
    
        public boolean isUploaded()
        {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            return facesContext.getExternalContext().getApplicationMap().get
    ("fileupload_bytes")!=null;
        }
    
       public String saveStyle()
       {
         System.out.println("Hello from saveStyle");
         return "Hello from saveStyle";
       }
    
    }
    But it is showing Error as

    cannot find symbol
    [javac] symbol : class UploadedFile
    [javac] private UploadedFile upFile;
    can anybody Help in this Regard
     
    Last edited by a moderator: Jan 5, 2007
  2. Goutham

    Goutham New Member

    Joined:
    Jan 4, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Plz send Reply to this Query
     
  3. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,287
    Likes Received:
    364
    Trophy Points:
    83
    Try using the code block for putting your code snippets in the post.

    Also moved the thread from Introduce yourself to JSP forum.
     

Share This Page