Displaying an image in my JSF page

Hello,
I am a beginner in JSF, and I wnat todisplay a picture loaded from my Data Base in my JSF page.
I follow this steps to get my image from my DataBase but I don't know how can I put it in my JSF page:
1/My image is stored in my Data base (Blob type)
2/I load this image from my database and Finally It stored it as a ObjectInputStream;
3/I don't know how can I display it in my JSF page because I don't know what I ll put in the url <h:graphicImage id="image" url="?"/>
please help me.
Edited by: user12066775 on 1 mars 2011 19:03

Write a servlet in Your application that will print the image (writing the stream from db to OutpuStream) for the specified id. In the url point to this servlet and pass the id param, or whatever else You need.

Similar Messages

  • How to display an image on the HTML page by using applet

    Dear friends,
    I am now writing an java applet, I want to display an image on the HTML page, and tried the following commands:
    {color:#ff00ff}{color:#000000}Image map; //put in the class definition
    map=getImage(getCodeBase(),"hhh.gif"); //put in the function of init()
    g.drawImage(map,0,300,this); //put in the function of paint(){color}
    {color}
    However, when I run it, the image wasn't displayed at all.
    I hope who guys ever come across this problem could help me to solve it. Thank you in advance!
    Hawaii

    Hi,
    I am no expert on Images
    but
    from personal exp.
    are you sure that map actually contains the image?
    try using
    ImageIcon ii = ImageIcon(String name);
    map = ii.getImage();I saw a tutorial on images i think on sun
    where they use ImageIcon to load the image

  • How to display date and time on jsf page

    Hi,
    how to display date and time on jsf page
    we are using 11.2.0.0 jdeveloper on windows.
    thanks
    Edited by: user12187801 on 26-Jul-2012 01:42

    Your question is certainly lacking some information.
    If you want a constantly updating date/time - then JavaScript is your best bet, and Google would find you examples like [url http://www.webestools.com/scripts_tutorials-code-source-7-display-date-and-time-in-javascript-real-time-clock-javascript-date-time.html]this
    If you meant something else, then it's back to you to explain.

  • PrepareRender() called multiple times if I have HTML/Images on a JSF page

    I have extended ADFPhaseListener and also FacesPageLifecycle. I am overriding the prepareRender() method in the CustomFacesPageLifecycle.
    When I insert an image on to the page in the branding facet or add any html using verbatim tag, the prepareRender() method is called two times. I am not sure why?
    If I remove the images/html, the method is only executed once.
    If I have image/html in the page, another strange thing is that the first time all the custom lines of code gets executed in prepareRender() method. But the second time only first few lines of code in the prepareRender() method. This seems to me a very wierd behaviour.
    Any inputs from ADF product dev team?
    Thanks
    - Amit Kochar

    Hi,
    if you add the following print statement
    System.out.println("rendering "+FacesContext.getCurrentInstance().getViewRoot().getViewId());
    Then the output in my case is
    07/04/24 08:14:04 rendering /BrowsePage.jsp
    07/04/24 08:14:05 rendering /otn_logo_small.gif
    The image comes from the file system, which means it is rendered by the JSF lifecycle. If you reference the image with a URL then the lifecycle doesn't render the image but only refrences it.
    To avoid your prepare render code to be executed multiple times, just check for jsp and jspx file extensions, which will guarantee that your code only executes for JSF pages, not for loaded files.
    The reason why this happens is because the JSF filter is set to /faces , which means all files that are loaded through that path
    Frank

  • Display BLOB Image in a JSP page.

    Hi, Is there any easy way to display a Image in the browser using a JSP and an Oracle BLOB. I would like any code examples that anyone can provide me. I would like as many ways to do this as possible.
    Thanks Brian

    You can do it in 2 ways:
    1. Get the BLOB from the DB and then write it into the local harddisk where the Web Server is located and then give the path in the <IMG SRC> Tag.
    2. In the JSP, when you specify a IMG Tag
    <IMG SRC='FileDisplayServlet?hdImgName=new.gif'>
    This SRC is pointing to a Servlet. The Servlet will read the Query String and then go hit the DB, get the BLOB Content and then convert into a byte array. Now the servlet will change its content type to image or gif. Then it will write the content in the out stream.
    Hope this helps.
    Thanks and regards,
    Pazhanikanthan. P

  • Reader X displays scanned images as blank, grey pages

    I have a great many PDFs (version 1.5) that are now unreadable with Acrobat X. These pages consist of scanned images that were converted to PDF, but now the pages are grey. You can search the OCR of the documents as before, but you can't see the pages. I have other PDFs that were created the same way at the same time, but don't have that problem, so it's inconsistent. The problem does not exist with Reader 9.

    In my case: v10.1.1 would not open more than one pdf at a time on a user workstation (although mine did) so I tried disabling protected mode and made sure the large image display setting was correct.
    To no avail. Reinstalled version base version 10, checked the same settings...no joy
      Also tried repairing the install and re-updated from the base v10...still no love
    Solution for me: Opened reader X, under Help-->Online Support, there is an option to generate a system report which availed the following:
    Graphics Card: NVIDIA GeForce FX 5200
        Version: 7.15.10.9685
        Check: Not Supported
    And of coarse the most recent driver was already present. Had to go back to v9.4
    All good now. Hope this saves someone a few hours!

  • I am trying to set up virtual servers with Netscape Enterprise Server 3.6. Can get home page to display but images linked to the page won't display and links to other pages won't work.

     

    hi,
    If your home page of the virtual server is displayed then,you have set the virtual server properly.
    check the links and source of the images or directories in the HTML source code of the home page.
    this should solve ur problem. If not notify me.
    Regards
    T.Raghulan.
    [email protected]

  • 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 : )

  • How to display a string in separate line in a jsf page?

    Hi,
    my view bean returns a string say, " Java Server Faces" .I just want to display all the three in a separate line like
    Java
    Server
    Faces
    If i go for concatenation or append method it is displaying in a way as before in java console.But when i display the same in a JSF page it is displayed as a single word.Can anyone help me in this?
    Thanks in Advance.
    Edited by: Swetha_Swetha on Feb 12, 2008 10:34 PM

    ya if we are passing three separate string values means we can use
    But am passing a single string value but appended as "Java"+"\n"+"Server"+"\n"+"Faces".
    In JSF page am just calling the method so, it should return the values in 3 separate lines.
    Thanks in Advance.

  • How to display an image of BLOB type from a Table in an OAF page?

    Hi,
    My requirement is that in the database table images gets saved of type BLOB and i have to display these images in my OAF page .I looked in OA developers guide and followed the instruction but unable to achieve my requirement .As per the developers guide "I created an item of type messageDownload ,in the viewattribute i set the view attribute FileData and File View Attribute FileContentType the table used is FND_LOBS" but i couldn't achieve anything.
    Please help me and if possible give me exact way to achieve it as i am new to this framework.
    Thanks in advance

    Map the database table columns to the Table region columns. For image column set the item style as "Messagedownload". Set the View Instance (VO) , View Attibute Name (image name) and View Attribute Data (blob col).

  • Displaying Image on th JSP page

    Hello All,
    I am using following code to display the image on the JSP page in my iView
    <% String PublicURL = componentRequest.getPublicResourcePath()+ "/images/Image1.gif"  ; %>
    <hbj:image id="Logo" width="70" height="35" 
                               src="<%= PublicURL %>"
                               alt= "picture Ericsson.gif" />
    Am I missing anything. I am still not able to display the image.
    Regards,
    Sanjeev

    change
    componentRequest.getPublicResourcePath()
    to
    componentRequest.getWebResourcePath()

  • Execute Logic Before JSF Page Is Processed

    In my task flow, I have two view activities.  When a user executes a specific operation, e.g., click on Submit command, in View A, the JSF page in View B is displayed.  View B's JSF page has three ADF components(2 forms and a table) that were created from different view objects in the Data Control section.  Before the JSF page is loaded, a method will execute the necessary logic for the three ADF components.  Is this possible?
    I am using JDeveloper 12.1.3.  I am not able to determine where I can specify the name of  the name of the method that will be invoked before View B's JSF page is invoked.

    You can add a method call in between when you navigate between A to B in your Task Flow.
    You can get some idea from this link :
    Johny's Tips: ADF: How to execute the ViewObject with a ViewCriteria on the PageLoad in ADF Web Application
    Cheers
    AJ

  • Why does my Safari 8.0.2 on Yosemite drop some image on html web pages ?

    Problem:
    Some images on the web(HTML) page not displayed. (images are dropped and displays as "?" marks)
    When I used OS X Mavericks, there was no problem.
    After updating OS X Mavericks to Yosemite, this problem has occur until now.
    I did do safe boot then something problems were fixed after removed Macafee.
    Question:
    How do I display all images on the web page without dropping them ?
    Environment:
    OS X 10.10.1 (Yosemite) updated from Mavericks
    Firewall: ON
    Stealth mode : ON
    Safari 8.0.2
    Mac book pro with Retina
    Removed Macafee All access ( it is not always compatible for Yosemite yet.)

    After update to Yosemite 10.10.2, Safari 8.0.2 was update to 8.0.3.
    Then this problem becomes to be much better.
    There are still some image dropped but Safari 8.03 is almost practical usage level now.
    By the way, I noticed that commercial message links on many web pages were often illegal SSL sites.
    It is not always perfect yet but new Safari 8.0.3 seems to defend us users from such illegal SSL links.
    There are wrong HTML descriptions problems on many web server sides.
    I can see some errors on the debug screen of Safari 8.0.3, I think this is good protection works by Safari 8.0.3.
    Especially Japanese newspaper sites have too many illegal SSL commercial message links.
    This situation should be solved by the web server programmers or managers.

  • 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.

  • Display multiple Images from a DB on a JSP Page!

    Hi all, please give me your solution, thanks. I have many images, stored in Oracle database (BLOB), How to display all of them (images) on a JSP page? I have a working solution that only shows one image based on the specific image-name passed. But if no image found in the Database with that image-name then I want to show all the images at once on a JSP page. Can someone help please. Follwing are the code snippets:
    Here is the JSP page that calls the servlet to show the images:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>untitled</title>
      </head>
      <body valign=center>
          <table>
            <tr>
                <td>
                    <img src="/test-testimgs-context-root/servlet/test1.images.servlet.GetImage">
                </td>
            </tr>
          </table>
      </body>
    </html>
    Here is the code that resides in the service method of GetImage servlet:
    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
        OutputStream stream = response.getOutputStream(); 
        Blob imgBlob = null;
        ResultSet rs = null;
        byte[] imbBytesAry = null;
        try
            ImageTest imgtest = new ImageTest();
            rs = imgtest.get("img1.tif");
            if(rs != null)
                while(rs.next())
                    imgBlob = rs.getBlob(1);
                    int len = new Integer( new Long( imgBlob.length()).toString() ).intValue();
                    imbBytesAry = imgBlob.getBytes(1,len);
                    if (imbBytesAry.length == 0 || imbBytesAry == null)
                        noImageFound(request, response); 
                    else
                        stream.write(imbBytesAry);
            else
                noImageFound(request, response);
        catch (Exception e)
            noImageFound(request, response);
    Here is the code that resides in the get method of ImageTest class:
    public ResultSet get(String fileName) throws DatabaseConnectionException, SQLException, Exception
    Connection connection=null;
    ResultSet rs = null;
    ResultSet rs1 = null;
    Blob imgBlob = null;
    try
        connection = new ConnectionProvider().getCConnection() ;
        connection.setAutoCommit(false);
        Statement stmt = connection.createStatement();
        String sql = "SELECT IMG FROM IMAGE_TABLE WHERE IMAGE_NAME = ? "; 
        PreparedStatement pstmt = connection.prepareStatement(sql);
        pstmt.setString(1,fileName);
        rs = pstmt.executeQuery();
        boolean flag = rs.next();
        if(flag)
            rs.beforeFirst();
        else
            sql = "SELECT IMG FROM IMAGE_TABLE"; 
            rs1 = stmt.executeQuery(sql);
            boolean flag_all = rs1.next();
            if(flag_all)
                rs1.beforeFirst();
            else
                rs1 = null;
        return rs;
    }As you see in the JSP page I am calling GetImage servlet, whose service method does all the processing i.e. calls ImageTest get method that queries the database and returns the result. Eventually what I would like is to pass the filename along with other parameters from JSP page and the servlet returns the images based on that. Currently I have just hard coded a value for testing puposes. Any help is appreciated.
    Thanks

    Hi all, please give me your solution, thanks. I have many images, stored in Oracle database (BLOB), How to display all of them (images) on a JSP page? I have a working solution that only shows one image based on the specific image-name passed. But if no image found in the Database with that image-name then I want to show all the images at once on a JSP page. Can someone help please.
    this is the code
    <form name="a" action="" method="post">
    <%
    rs1 = st1.executeQuery(select1);
    rs1.next();
    while(rs1.next())
    %>
    <table>
    <tr><td>
    <%
    Blob objBlob[] = new Blob[rs1.getMetaData().getColumnCount()];
         for (int i = 0; i <= rs1.getMetaData().getColumnCount(); i++)
               objBlob[i] = ((OracleResultSet)rs1).getBLOB(1);
              InputStream is = objBlob.getBinaryStream();
    byte[] bytearray = new byte[4096];
    int size=0;
    response.reset();
    response.setContentType("image/jpeg");
    response.addHeader("Content-Disposition","filename=getimage.jpeg");
    while((size=is.read(bytearray))!= -1 )
    response.getOutputStream().write(bytearray,0,size);
    response.flushBuffer();
    is.close();
    out.println("hhhhhhh");
    %>
    </table>
    <%
    rs1.close();
    //con.close();
    %>
    </form>

Maybe you are looking for

  • Delimiting an  Org Unit when the sub ordinate relationships still exist.

    Hello All, I tried to delimit an Orgunit when there are subordinate positions already assigned. I am able to delimit without ending the relationships first. Why SAP is letting do this. Now after the delimit I have Orgunit with end date of 06/22/2207,

  • Oracle Intelligent Agent cannot be started

    I have installed Oracle 9i into RedHat Linux 9. When I start the Oracle Intelligent Agent, I get nothing response, and find the agent cannot be started. I find the error message in dbsnmp.nohup which is showed below: /opt/ora9/product/9.2/bin/dbsnmp:

  • Scaling on WAD valuce axis

    Dear experts, can you please guide me how to apply scaling on value axis in WAD. Requirement is we need to have 0, 20000, 40000, 60000 .....  on Y-axis (value axis) in WAD. Thanking you in advance. Regards, Ravi Kumar VR Garre

  • Date format mask failure stops navigation

    I'm trying to allow users to enter dates in multiple formats. My date items already have format mask 'YYYY-MM-DD'. I have added ON-ERROR code that handles errors like FRM-50003 so that users can enter '29-APR-2011' and the error handler fills the dat

  • Repeating the Image for page optimization

    Hello, Pl. suggest how to repeat the image vertical / horizontal, to make the page optimization in Dreamweaver in Design mode. Ex. : with small dot (image) to make a line. Regards