How to upload a Folder in JSP

Can any one assists me in uploading a folder in the JSP.
I am working on the struts frame work.
This is required because ,some time when a client downloads a html page, it may download with it some images also which are stored in another folder.
so when he is uploading this file to some other server then the folder should also be uploaded along with.
Thanks in advance

But say if he specifies a folder instead of file ,then ?
The file type in the html tags is an editable field,so he may select upto a folder level only.
Then what would be the solution for this ?
thanks in advance.
srikandula

Similar Messages

  • How to upload an image in jsp page

    hi,
    I want to upload an image file with my jsp page, but i cannot do it,
    I have used Jakarta common file upload for this & i have also read following file. But my code isnot working properly? Can you give me any example how to upload an image & how to display it?
    Can u give me any source code? Please help me.
    http://jakarta.apache.org/commons/fileupload/using.htmlwith regards
    Bina

    Hi,
    But after writing the following code i have got following error? What's the problem of this code? please help me?
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    <%@ page import="org.apache.commons.fileupload.*" %>
    <%@ page import ="java.util.*" %>
    <%@ page import ="java.io.*" %>
    </head>
    <body>
    <%
    boolean isMultipart = FileUpload.isMultipartContent(request);
    DiskFileUpload upload = new DiskFileUpload();
    List items = upload.parseRequest(request);
    Iterator iter = items.iterator();
    while (iter.hasNext()) {
    FileItem item = (FileItem) iter.next();
    if (item.isFormField()) {
    String name = item.getFieldName();
    String value = item.getString();
    //ring name= request.getParameter("")
    %>
    <%= name %>:<%= value %>
    <%
    } else {
    %>
    <%
    InputStream stream = item.getInputStream();
    OutputStream bos =
         new FileOutputStream(getServletContext().getRealPath("/images"+"/"+ item.getName()));
    int bytesRead = 0;
    byte[] buffer = new byte[8192];
    while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
    bos.write(buffer, 0, bytesRead);
    bos.close();
    stream.close();
    item.delete();
    %>
    </body>
    </html>Error is:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileUpload cannot be resolved
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileUpload cannot be resolved
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    DiskFileUpload cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
    An error occurred at line: 13 in the jsp file: /uploadfileC.jsp
    Generated servlet error:
    FileItem cannot be resolved to a type
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)Please help me.
    With regards
    Bina

  • How to Upload a file in JSP ( doc,  txt ) as an attachment

    I want to upload a file using JSP. I tried Jason's Multipart program, but it is creating some problem. Pls suggest me the alternate. How to write a code. Is there any bean available for free download. Pls. help me.
    - Ashok Mudalagi
    [email protected]

    I have successfully used Multipart classes from Oreilly. I believe that's the same one you are referring to. I have implemented my Upload using a servlet though. If you can post what exactly is your trouble using that code, I will be glad to help you with it.

  • How to upload a file in jsp

    Hi ,
    I have to attach file and then when i click save it should be saved in a database.How can i do this.Pls help me.
    Thanks
    Naveen

    Try jspSmartUpload at http://www.jspsmart.com . I use it and it works great.
    Also, do a search on uploads on this site. This question has been answered many times before.
    Hope this helps,
    JEB

  • How to Upload in Servlet or JSP with JavaBean?

    Anybody used to be familiar with these techs?I want to implement a function of upload files.Can you help me with some suggestions?

    Hi,
    This might help you
    read the file and upload to database
    Read that file using java.io.
    File f= new File("give the file name");
    FileInputStream fis= new FileInputStream(f);
    byte[] data= null;
    Vector tempVector = new Vector();
    int tempInt=fis.read();
    while(tempInt!=-1){
    tempVector.add(new Byte((byte)tempInt));
    tempInt=fis.read();
    data= new byte[tempVector.size()];
    for(int k=0;k<tempVector.size();k++){
    data[k]=new Byte(tempVector.get(k).toString()).byteValue();
    System.out.println("The byte[] data is : " +data);
    stmt= conn.prepareStatement("insert into <tableName>(blobValue, key) values ( ? , ? ) " );
    stmt.setObject(1,data);
    stmt.setString(2,"filename");
    stmt.executeUpdate();

  • I have to upload a folder to the server

    Hi all,
    My requirement is i have to upload a folder through jsp page to the tomcat server, but i am not aware of that, i know only file uploading using html tal type=file, so can any one please send me the code to upload a folder to the server(specified place). Means i want to place the folder in the specified position in the server(how can i specify the path) and after that i have to read the contents(jpeg images) present in that folder(now how can i get the path) and place them in the DB, so can any body kindly send me the coding for this requirement. Send me all the necessary required files for this including (jsp file, java bean(if necessary .java file for that jsp page)).
    Waiting for the reply.
    sasi.

    giyf.... amongst many others
    http://www.jguru.com/faq/view.jsp?EID=160

  • How to upload a file using java bean?

    hi,
    i need a code simple how to upload a file from jsp form to a java bean file (not a servlet)
    thank,s zik

    Hi,
    i need a code sample how to upload a file from jsp
    form to a java bean file (not a servlet)You can use jspSmartUpload component which is a free, fully-featured JSP component.
    jspSmartUpload provides you with all the upload/download features you could possibly wish for :
    * Simple and complete upload
    * Total control over the upload process
    * �Mixed forms� management
    * Total control over files sent
    * Download whatever you want
    For further information about jspSmartUpload please visit
    http://www.jspsmart.com/
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Micro Sysytems
    http://www.sun.com/developers/support/

  • Upload Entire Folder with Files to Web Page

    Can someone please inform me how to upload a Folder with multiple files in the folder. We have many many files that we need to have viewed on the outside but don't want to have to link every single file. I am using CS5.
    Thank you!

    Hello-
    I did exactly what you said. I created the folder on the local and the local and remote folder do match. I created the link and uploaded everything. When I click on the link I receive an error message "HTTP 403 Forbidden". Can you please tell me what this means, what I may be doing wrong. Does this mean that directory browsing is disabled? How do you use a server side script that dynamically reads the file system and creates links?
    Thank you!
    The website declined to show this webpage
    HTTP 403
    Most likely causes:
    This website requires you to log in.
    What you can try:
    Go back to the previous page.

  • How to upload image from a folder thro JSP

    Hi,
    I am CBK Varma,and I am developing one application, where
    I have to display images in my webpage, from a specific folder that should keep on changing every 10 sec.. ...
    how to upload these image files to my page with timing..means afterr 10 sec ,the another image in the same folder has to be dis[play.
    I am storing images ina folder as .jpg/.gif format. (thro Java Program).
    Plz tell me the way of how to do this?
    Thanks in advance.
    Varma.

    These image files reside on the client? If so the client is going to have to initiate the upload. Think of the security problems if they didn't?

  • How to upload a text file from a shared folder and provide an o/p

    how to upload a text file from a shared folder and provide an o/p  containing the details in each order in the text file

    Hi,
    Use <b>GUI_UPLOAD</b> to upload a text file from a shared folder.
    Use <b>GUI_DOWNLOAD</b> to download data in a file on the presentation server or use <b>OPEN DATASET, TRANSFER</b> and <b>CLOSE DATASET</b> statements to download data to the application server.
    Now, I hope the code for data fetching, if required, is already present in the report.
    Reward points if the answer is helpful.
    Regards,
    Mukul

  • How to upload a file in BPEL Console Using JSP in JDeveloper, pleae........

    I am very new to this JDeveloper & BPEl Process , please could some one help in ersolving my problem that is , how to upload a file in BPEL Console Using JSP in JDeveloper.

    Hi,
    ADF Faces provides you with the file upload component
    http://download-uk.oracle.com/docs/html/B25947_01/web_complex006.htm#CEGCEDHF
    http://download-uk.oracle.com/docs/html/B25947_01/appendixa007.htm#CHDEDCFA
    This gives you a handle to the file content. However, uploading files through a service is different and I suggest to consult teh BPEL forum for this BPEL
    Frank

  • How to upload a file in BPEL Console Using JSP in JDeveloper, please help..

    Please I am new to Jdeveloper and to BPEL Process of OASuite,I want to know , how to upload a file in BPEL process using JSP in Jdeveloper IDE.
    The main aim is first we need to upload a file in JSP , it has to go to BPEL Process & it has to read the file & write the respective file in return to JSP through BPEL Process. Please I am in Urgent need of the Query , please help me ASAP.
    Send to me response Please.....................................

    Hi,
    I thin that you asked the same question before and I premember that I ointed you to the ADF BC developer guide and the SRDemo if your application uses JSF. For plain JSP - if you Google for: JSP and file upload then you find plenty of sources for JSP and Struts.
    The remaining part is how to stiff the file into a BPEL service on the middle tier. For this I recommended to ask your question on the BPEL forum
    BPEL
    Note that the BPEL integration would be easier if it was done on the middle tier and not onthe client
    Frank

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • How to upload a file into server using j2ee jsp and servlet with bean?

    How to upload a file into server using j2ee jsp and servlet with bean? Please give me the reference or url about how to do that. If related to struts is more suitable.
    Anyone help me please!

    u don't need j2ee and struts to do file uploading. An example is as such
    in JSP. u use the <input> file tag like
    <input type="file"....>You need a bean to capture the file contents like
    class FileUploadObj {
        private FormFile srcFile;
        private byte[] fileContent;
        // all the getter and setter methods
    }Then in the servlet, you process the file for uploading
        * The following loads the uploaded binary data into a byte Array.
        FileUploadObj form = new FileUploadObj();
        byte[] byteArr = null;
        if (form.signFile != null) {
            int filesize = form.srcFile.getFileSize();
            byteArr = new byte[filesize];
            ByteArrayInputStream bytein = new ByteArrayInputStream (form.srcFile.getFileData());
            bytein.read(byteArr);
            bytein.close();
            form.setFileContent(byteArr);
        // Write file content using Writer class into the destination file in the server.
        ...

  • HOW TO  upload OF URL ITEM INTO FOLDER programmatically

    Does anybody know how to upload URL item into folder
    programmatically either using sql command or PL/SQL.
    Please help...because I need to upload about 10,000 of URL link
    into a folder. Doing this one by one might not practical.
    Thanks.

    Please refer to the content area APIs. These are documented in
    the PDK-PL/SQL.
    Regards,
    Jerry

Maybe you are looking for