Display uploaded file on JSP page

Hi All,
I want to display uploaded file in JSP.
Initially I am displaying File Name after saving the file & click on edit link.
i.e on JSP Page I have File Upload component & save button.With that save button I am saving my file to databse.
So when I click on edit link I am getting that file name from Databse then I am displaying it.
But now I want to display uploaded file name on JSP page before saving to databse.i.e I will have browse & Upload button.When I click on browse button I will open window from where I will select file.
This is working fine as,<x:inputFileUpload id="uploadfile" value="#{errorLotBean.file}" storage="file"></x:inputFileUpload>
But when I click on upload button that uploaded file should be displyed there only.Can anyone please tell me how to do this ?
Thanks
Sandip

Thanks a lot Siefert,
I tried the way mentioned in URL.
But what if I want to display all uploaded file on my screen.
i.e. If user click on browse & select File A then click on upload button.
(Here the File A will be displayed) with code
<h:outputtext value="#{benaName.file.name}"
But what if after displaying File A if user decide to upload another file File B.
How to display that ?
with <h:outputtext value="#{benaName.file.name}" its dispalying one file only.
Thanks
Sandip

Similar Messages

  • How to display uploaded image in jsp page.

    Hello,
    I am using struts 1.2.9 and and have uploaded image on the server. Now what I want to do display the image in jsp page after clicking on one link in jsp. I have tried many thing to display image in jsp page. But I am getting an error during displaying image in jsp. I have displayed absolute path in servlet. and used InputStream and outputstream to display image in jsp page.
    Can any one help.
    Thanks in advance
    Manveer Singh

    Follow this. This topic is very popular recently on the forum.

  • How can i render a dynamic html file in jsp page

    Hi everybody,
    i am trying to render a dynamic html file in jsp page with the result of querying a database.
    The response of the query is a xml document. And i have a stylesheet to transfer it to html.
    How can i render the html in a jsp file?

    I am using below code for HTML files
    private var appFile:String="index.html";
    if (StageWebView.isSupported)
                        currentState = "normal";
                        webView.stage = stage;
                        webView.viewPort = new Rectangle( 10, 130, (stage.stageWidth)-20, 750 );
                        var fPath:String = new File(new File("app:/assets/html/aboutus/"+ appFile).nativePath).url; 
                        webView.loadURL(fPath);
                        addEventListener(ViewNavigatorEvent.REMOVING,onRemove);
                    else {
                        currentState = "unsupported";
                        lblSupport.text = "StageWebView feature not supported";
    above code is working fine for me.

  • How to display flash file in adf pages

    how to display flash file in adf pages need help

    Thanks all,
    It is resolved.
    the code i am using to display a flash is below.
    <f:verbatim>
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version
    =10,0,0,0" width="300" height="300" id="11gR1_aniH_grey" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="allowFullScreen" value="false" />
    <param name="wmode" value="transparent" />
    <param name="movie" value="mx2004demo.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#4d5c64" />     
    <embed src="../Images/mx2004demo.swf" quality="high" width="300" height="300" name="mx2004demo.swf" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false"
    type="application/x-shockwave-flash" wmode="transparent"
    pluginspage="http://www.adobe.com/go/getflashplayer" />
         </object>
    </f:verbatim>

  • How can i call java class file in jsp page

    Hai,
    i wants to call .class file in jsp page.
    my class file is in C:\jsdk\bin.
    Thanks

    I'm not entirely sure what you mean by "calling a class file", but I'm going to assume that you want to do something like the following in your page:
    <%
    MyClass myClass = new MyClass();
    myClass.someMethod();
    %>etc
    If that's the case, then all you have to do is make sure that the class is in the servlet engine's classpath. You'll probably also need to include an appropriate import statement at the top of the page.
    Hope that helps.

  • Forwarding to an xml file from jsp page

    hi
    i am subhash. i have problem in forwarding an xml file from jsp page.
    i have a jsp page in which i have a button. upon click, its form method is triggered and the action is set to "serverpage.jsp". In that jsp page i have to move to an xml file. I would like u to send a sample code also for the same.
    Thank You,
    Subhash..

    Refer to the Generating XML from JSP section.
    http://java.sun.com/developer/technicalArticles/xml/WebAppDev2/

  • Open File Dialog - JSP pages

    If I create a jsp page with an open file dialog will it work no matter what OS people are running? What I want to do is attach a file. It would be preferrable if I could set a "working" directory and when I open up the dialog it starts in that directory. It has to work with Windows, Macs, and Linux . If there is no way to set the "working" directory, can a cookie be created that remembers the last directory accessed from the page so that when they open up the dialog it opens up under the last directory accessed?

    there is a html input type that sparks up the OS native filechooser. Thus, it should be platform independent. You should look into Apache Commons FileUpload, as it makes the process of uploading/sending files ridiculously easy.

  • How to Display jFrame - chart in JSP PAge

    Hi all,
    Can any one help about this task..
    I have writeen a java file which generates multiaxis chart by using JFreeChart API....
    Say for ex..
    public class multiaxis extends JFrame
    /// till know no problem...
    Can any one tell its possible to display this chart (JFrame) in Browser (JSP Page) .. any idea over this..
    Thanks in advance

    there's examples around the forums about using JFreeChart in a servlet to generate a JPEG or PNG images.

  • How to list the uploaded files  in jsp

    hello every body .
    I wanted to request to plese let me know the method as to how get the uploaded files on the server to a jsp page . i am able to upload the files but not able to get those files listed on the web page . please help me ...........

    i tried this also and it didn't wok instead my page got filled with these lines
    The file named CSAJSP-Chapter12.pdf is successfully uploaded [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0 [Ljava.lang.String;@1ab11b0
    . I am not able to make out any thing . plese  suggest me  some solution                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Reading text files in JSP pages

    I want to know if it's possible to read a file and display it in an html:text area on a jsp page.
    What I have right now is:
    <html:file property="theFile" style="query-table-item" onclick="uploadFile(document.searchReportForm.theFile);"/> <html:reset title="Reset"/>what I wish to do, is to implement the uploadFile function, so that it can read from a text file and display it's contents onto the html:file area.
    uploadFile is a javascript function that is being called from a javascript file.
    I want to know if I can read the browsed file using javascript.
    and if so, does someone have an idea how to do it?
    Please help me out.

    Double post http://forum.java.sun.com/thread.jspa?threadID=647550&tstart=0

  • Upload file using jsp

    hi all i am trying a code that uploads file to the server using jsp the code goes like this
    <%@ page import = "java.io.*" %>
    <%
    String contentType = request.getContentType();
    String file = "";
    String saveFile = "";
    FileOutputStream fileOut = null;
    if((contentType!=null)&&(contentType.indexOf("multipart/form-data")>=0))
       DataInputStream in = new DataInputStream(request.getInputStream());
       int formDataLength = request.getContentLength();
       byte dataBytes[] = new byte[formDataLength];
       int byteRead = 0;
       int totalBytesRead = 0;
       while(totalBytesRead<formDataLength)
          byteRead = in.read(dataBytes,totalBytesRead,formDataLength);
          totalBytesRead +=byteRead;
       try
          file = new String(dataBytes);
          saveFile= file.substring(file.indexOf("filename=\"")+10);
          saveFile = saveFile.substring(0,saveFile.indexOf("\n"));
          saveFile =
          saveFile.substring(saveFile.lastIndexOf("/")+1,saveFile.indexOf("\""));
          int lastIndex = contentType.lastIndexOf("=");
          String boundary =
          contentType.substring(lastIndex+1,contentType.length());
          int pos;
          pos = file.indexOf("filename=/" +1);
          pos = file.indexOf("\n",pos)+1;
          pos = file.indexOf("\n",pos)+1;
          pos = file.indexOf("\n",pos)+1;
          int boundaryLocation = file.indexOf(boundary,pos) - 4;
          int startPos = ((file.substring(0,pos)).getBytes()).length;
          int endPos =
          ((file.substring(0,boundaryLocation)).getBytes()).length;
          String folder = "07ics01/jsp/"; //is this the folder where i intend to save the file?
          fileOut = new FileOutputStream(folder + saveFile);
          fileOut.write(dataBytes);
          fileOut.write(dataBytes,startPos,(endPos-startPos));
          fileOut.flush();
       catch(Exception e)
          out.println(e);
       finally
          try
             fileOut.close();
          catch(Exception err)
    %> i have been trying to use this code but i can't understand the code. is String folder = "07ics01/jsp" the folder where i intend to save the page on the server? because when i do that i get an exception like
    java.io.FileNotFoundException: 07ics01/jsp/C:\Documents and Settings\s9sharma\Desktop\tt\commons-digester-1.8\commons-digester-1.8.jar (No such file or directory) where C:\Documents and Settings\s9sharma\Desktop\tt\commons-digester-1.8\commons-digester-1.8.jar is the file i am trying to upload to the directory 07ics01/jsp which is a unix directory.
    Can anyone please help..

    So you've copypasted this code from somwhere and are expecting our support on the code, instead of the author's support? That's sad.
    I recommend you to look to the Apache Commons FileUpload API [1]. Then you don't need to write (or copypaste) a multipart parser yourself. Putting business logic in JSP files is also bad practice by the way. Use Java classes for it instead (Servlets, Filters, Beans, Utilityclasses, etc).
    [1] http://commons.apache.org/fileupload/
    To understand the actual code, it might help a lot to first read and understand the HTML spec about multipart request data and read the API documentations of the Java classes involved, e.g. the java.io API.

  • Importing avi files into jsp pages

    hello all. im new to jsp and java. i would like to know how i could import .avi files from my MySQL database (where ive given paths for the avi files) into a jsp page. i am basically trying to make an application that allows users to select particular video files and play them. the user has the ability to upload and delete these videos

    newbie4337 wrote:
    im sorry i guess i didn't phrase that properly. i meant to say that i had saved the paths in the database If you have some saved URLs in the database (URLs to where these avi files can be found)
    you just need to retrieve the URLs and use them when generating links (<a href="..."></a>) in the html produced by your JSP.
    You have already given the paths in the html generated by your jsp? Paths as in URLs?
    Then you must already have a servlet deployed that accepts HTTP requests for .avi URLs and reads the relevant .avi from the database and serves back an avi stream with the right mime type (video/x-msvideo) in the headers...
    ([w3schools|http://www.w3schools.com/media/media_mimeref.asp]).
    could you give me some more info on that?If the URLs are hosted somewhere else you do not need any of this.

  • Loading Java Class File in JSP page

    I'm trying to load a java class file from a jsp page.
    (e.g. MyFile.java <-- Source "MyFile.class<--Class file of MyFile.java")
    jsp page
    <%@ include file = "MyFile.class" %>
    <HTML> // HTML Tags are here
    MyFile.java
    A normal java source file that has "public static void main" in it.
    My jsp page can display it's contents, 'except' for showing e.g. "1235%%215648%%public%%$$@##" through out the page...
    My guess is that it can't display my java class file..
    Can anyone please help me solve this problem of mine ?
    Thanks in advance : )
    Yours Sincerely,
    RainbowEnergies

    This is my JSP file.
    <HTML>
    <HEAD>
    <TITLE>Activity Games</TITLE>
    </HEAD>
    <%
    String name = "";
    String id = "";
    name = session.getAttribute("name").toString();
    session.setAttribute("name",name);
    id = session.getAttribute("id").toString();
    session.setAttribute("id",id);
    %>
    <BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
    <H3><%=name%>, you have enter Activity Games</H3>
    <%@ page import="Games.Lufia.*" %>
    <%Lufia lufia = new Lufia();%>
    </BODY>
    </HTML>
    After I execute...
    An error occurred at line: 18 in the jsp file: /jsp/ActivityGames.jsp
    error: File C:\Program Files\Apache Tomcat 4.0\webapps\website\WEB-INF\classes\Games\Lufia\Lufia.class does not contain type Games.Lufia.Lufia as expected, but type Lufia. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\website\jsp\ActivityGames$jsp.java:85: Class Games.Lufia.Lufia not found.
    Lufia lufia = new Lufia();
    But if I comment this out....
    This is my JSP file.
    <HTML>
    <HEAD>
    <TITLE>Activity Games</TITLE>
    </HEAD>
    <%
    String name = "";
    String id = "";
    name = session.getAttribute("name").toString();
    session.setAttribute("name",name);
    id = session.getAttribute("id").toString();
    session.setAttribute("id",id);
    %>
    <BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
    <H3><%=name%>, you have enter Activity Games</H3>
    <%@ page import="Games.Lufia.*" %>
    <%//Lufia lufia = new Lufia();%> <--- comment this out.... (HERE)
    </BODY>
    </HTML>
    The page shows but did not run my java class file..
    Thanks again for trying to help me solve this problem of mine. : - )
    Regards,
    RainbowEnergies

  • Displaying calculated data in JSP pages

    This is a general question about displaying data in JSP pages which has been calculated through ViewObj Routines. I have exposed the methods to the application level however, I want these methods to automatically run on the launch of the page. I can so this with a data action in the struts file. However, I have lots of these methods (all bringing single values of data), it seems inelegant to have 10 data actions or so. What's the best way to expose and show data on a JSP page automatically which has been calculated from the database rows.
    Thanks in advance

    You could convert the vo row to a hash using BeanUtils and then you could do what you want with it programmaticaly to automatically dissplay the lhash values.

  • Problem with displaying BLOB images on JSP page using a servlet

    hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that servlet, that is http://localhost:8080/ImageServlet. It doesn't work when i try to use that servlet to display my image on my JSP page (my JSP page displays only a broken-image icon ) I tried several coding approaches with my servlet (used both Blob and BLOB objects), and they work just fine as long as i display images explicitly using only the servlet.
    Here's what i use : ORACLE 10g XE , Eclipse 3.1.2, Tomcat 5.5.16 , JDK 1.5
    here is one of my image servlet's working versions (the essential part of it) :
                   BLOB blob=null;
              rset=st.executeQuery("SELECT * FROM IMAGES WHERE ID=1");
              while (rset.next())
                   blob=((OracleResultSet)rset).getBLOB(2);
              response.reset();
              response.setContentType("image/jpeg");
              response.addHeader("Content-Disposition","filename=42.jpeg");
                    ServletOutputStream ostr=response.getOutputStream();
                   InputStream istr=blob.getBinaryStream(1L);
                    int size=blob.getBufferSize();
              int len=-1;
                    byte[] buff = new byte[size];
                         while ((len=istr.read( buff ))!=-1 ) {
                   ostr.write(buff,0,len);
             response.flushBuffer();
             ostr.close(); and my JSP page code :
    <img src="/ImageServlet" border="0"  > If you could just tell me what i'm doing wrong here , or if you could show me your own solutions to that problem , i would be very greatful ,cos i'm realy stuck here , and i'm rather pressed for time too. Hope someone can help.

    I turns out that it wasn't that big of a problem after all. All i had to do was to take the above code and place it into another JSP page instead of into a servlet like i did before. Then i just used that page as a source for my IMG tag in my first JSP. It works perfectly well. Why this doesn't work for servlets i still don't know, but it's not a problem form me anymore . Ofcourse if someone knows the answer , go ahead and write. I would still appriceatte it.
    here's the magic tag : <img src="ImageJSP.jsp" border="0"  > enjoy : )

Maybe you are looking for

  • Import from Project

    How can I get msproject data into powerpivot? Do I need project installed, or is there a way to retrieve the data without instaling it (as you can do with access) Thanks

  • Numbers into textfield using boolean buttons and case structure?

    Hi! I'm very new to these forums, and to LabVIEW in general. I'm currently trying to implement a calculator-ish, but without the operations (+ - * /). I have 10 boolean buttons, named 0-9, and with these I want to basically write a sequence of number

  • Operating system issues

    I just downloaded the IOS update 7.0.6 on my ipad, and now my bookmarks are gone in Safari, and my keyboard has a huge time lag when typing. Can I fix these issues ?

  • USB mic or buy amp or mixer

    Forgot to say earlier, would buying a usb mic and putting it into computer instead of using my old one [and buying an amp or mixer ]give me a decent clear volume in my vocals. Just trying to find the simplest least expensive yet effective way. Thanks

  • WebLogic SAML 1.1 & Apache as proxy & SSL between browser and Apache

    Hi, I'm trying to configure SAML 1.1 to work with WebLogic Server 10.3. Here is a short description of the configuration - Browser connects to Apache front end with ssl https://myserver:444/... - Apache proxies requests to WebLogic Server instances i