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()

Similar Messages

  • Dynamic Image rendering on JSP page

    Hi All!
    I want to display images on my JSP page. However, the images should be generated dynamically (As are used by many sites during the registration process e.g., yahoo, etc..) How can i achieve this?
    plz help! Its urgent!

    Yes, but your in the wrong forum for this.
    Use the search bar to look for posts and have a look in
    http://forum.java.sun.com/forum.jspa?forumID=5
    There are forums on Multimedia which may also have some information.

  • HOWTO: Display a custom image on a jsp page

    You need 4 files.
    1. a jsp page (index.jsp)
    2. A servlet (myPackage.ImageMaker)
    3. A supplier class (myPackage.PluggableSupplier)
    4. web.xml (your IDE should supply this)
    From the jsp page you're calling the servlet with an <img> tag, and passing it some parameters.
    The servlet obtains a BufferedImage from a pluggable supplier class, and returns with an image (png).
    The image is displayed on the jsp page. Hope this helps!
    ================================================================================================
    Here's the .jsp file (index.jsp)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>Image page</title>
        </head>
        <body>
        <h1>Your image:</h1>
        <img src="ImageMaker?Param1=Hello world&Param2=Hello again" />
        </body>
    </html>================================================================================================
    Here's the servlet (ImageMaker.java):
    package myPackage;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ImageMaker extends HttpServlet {
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            System.out.println("called");
            //Prevent chacing of the image as it's probably intended to be 'dynamic'
            response.addDateHeader("Expires", 795294400000L); //<--long ago
            response.addHeader("Cache-Control", "no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
            response.addHeader("Pragma", "no-cache");
            //set mime type and get output stream
            response.setContentType("image/png");
            OutputStream out = response.getOutputStream();
            //catch incoming parameters, as many or few as you want
            String parameter1 = request.getParameter("Param1");
            String parameter2 = request.getParameter("Param2");
            //fetch the buffered image
            int width = 100;
            int height = 50;
            PluggableSupplier ps = new PluggableSupplier(width, height);
            BufferedImage buf = ps.fetchBI(parameter1);
            /***You can now draw on the original image if you want to add a watermark or label or whatever*********/
            Graphics g = buf.getGraphics();
            g.setColor(Color.BLACK);
            g.drawString(parameter2, 5, 30);
            try {
                System.out.println("writing...");
                ImageIO.write(buf, "png", out);
            } catch(IOException ioe) {
                System.err.println("Error writing image file: " + ioe);
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
    }================================================================================================
    This is the class that supplies your image (PluggableSupplier.java):
    package myPackage;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    public class PluggableSupplier {
        BufferedImage buf = null;
        Graphics2D g2d = null;
        int width = 50;
        int height = 50;
        public PluggableSupplier(int w, int h) {
            if ((w+h)>2) {
                this.width = w;
                this.height = h;
            buf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            g2d = buf.createGraphics();
        public BufferedImage fetchBI(String parameter1) {
            if (g2d != null) {
                g2d.setColor(Color.RED);
                g2d.fillRect(0, 0, width, height);
                g2d.setColor(Color.WHITE);
                g2d.drawString(parameter1, 5, 15);
            return buf;
    }================================================================================================
    finally, your web.xml should look like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
        <servlet>
            <servlet-name>ImageMaker</servlet-name>
            <servlet-class>myPackage.ImageMaker</servlet-class>
        </servlet>
        <servlet-mapping>
            <servlet-name>ImageMaker</servlet-name>
            <url-pattern>/ImageMaker</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <welcome-file-list>
         <welcome-file>
                index.jsp
            </welcome-file>
        </welcome-file-list>
    </web-app>null

    Another trick I learned (the hard way ;))...it's a good idea to buffer the output before responding. Add the following code to the servlet, in the case of the provided example, where all the other response-related stuff are done:
    response.setBufferSize(yourBufferSize);It's a good idea to try and calculate the buffer size as accurately as possible.

  • Display Image in another jsp

    hello,
    I am facing a design issue of so as to how to go about displaying an image which i am retrieving from database.
    I have a SubmitDoc.jsp which takes as input the doc id which i need to display looks like :
    *SubmitDoc.jsp*
    <FORM METHOD=POST ACTION="Retrieval">
    Enter Document ID to Retrieve: <INPUT TYPE=TEXT NAME=DOCID SIZE=20/><BR>
    <P><INPUT TYPE=SUBMIT></P>
    </FORM>I have my Retrieval servlet which access the DB and gets the binary stream for the image data based on DOCID.
    Now i try to forward result to a different jsp in order to display the binary data from the servlet.
    something like this :
    InputStream readImg = rs.getBinaryStream("DOCUMENT");
    response.setContentType("image/jpg");
    request.setAttribute("ImageData", readImg);
    // response.getOutputStream().write(rb,0,len);
    RequestDispatcher rd = request.getRequestDispatcher("DisplayDoc.jsp");
    rd.forward( request, response );What code should i put in DisplayDoc.jsp to show the image there.
    Any ideas how do i go about ?
    Thanks,

    What code should i put in DisplayDoc.jsp to show the image there.The same code you put in any html page to show an image:
    <img src="urlToDownloadImageFrom"/>In effect you have two requests.
    One for the JSP page, and then another for the image.
    So often what you find is the tag on your page needs to pass the id as well
    <img src="/ImageServlet?docId=abc123"/>

  • 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 retrieve records from a database and display it in a jsp page.Help!!

    Hello everyone ! im very new to this forum.Please help me to solve my problem
    First i ll explain what is my requirement or needed.
    Actually in my web page i have text box to enter start date and end date
    and one list box to select the month .If user select or enter the dates in text box
    accordingly the data from ms access database has to display in a jsp page.
    Im using jsp and beans.
    I tried returning ResultSet from bean but i get nothing display in my web page
    instead it goes to error page (ErrorPage.jsp) which i handle in the jsp.
    I tried many things but nothing work out please help me to attain a perfect
    solution. I tried with my bean individually to check whether the result set has
    values but i got NullPointerException . But the values which i passed or
    available in the database.
    I dint get any reply for my last post please reply atleast to this.
    i get the date in the jsp page is by this way
    int Year=Integer.parseInt(request.getParameter("year"));
    int Month=Integer.parseInt(request.getParameter("month"));
    int Day=Integer.parseInt(request.getParameter("day"));
    String startdate=Day+"/"+Month+"/"+Year;
    int Year1=Integer.parseInt(request.getParameter("year1"));
    int Month1=Integer.parseInt(request.getParameter("month1"));
    int Day1=Integer.parseInt(request.getParameter("day1"));
    String enddate=Day1+"/"+Month1+"/"+Year1;But this to check my bean whether it return any result!
    public void databaseConnection(String MTName,String startDate,String endDate)
    try
             java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
            java.sql.Date sqlFromDate=new java.sql.Date(fromDate.getTime());
            java.sql.Date sqlTillDate=new java.sql.Date(tillDate.getTime());
              String query1="select MTName,Date,MTLineCount from Main where MTName='"+MTName+"'  and Date between '"+sqlFromDate+"' and '"+sqlTillDate+"' " ;
            System.out.println(query1);
              Class.forName(driver);
             DriverManager.getConnection(url);
             preparedStatement=connection.prepareStatement(query1);
             preparedStatement.setString(1,"MTName");
              preparedStatement.setDate(2,sqlFromDate);
              preparedStatement.setDate(3,sqlTillDate);
              resultSet=preparedStatement.executeQuery();           
               while(resultSet.next())
                        System.out.println(resultSet.getString(1));
                        System.out.println(resultSet.getDate(2));
                        System.out.println(resultSet.getInt(3));
            catch (Exception e)
             e.printStackTrace();
    I Passed value from my main method is like thisl
    databaseConnection("prasu","1/12/2005","31/12/2005");Please provide solutions or provide some sample codes!
    Help!
    Thanks in advance for replies

    Thanks for ur reply Mr.Rajasekhar
    I tried as u said,
    i tried without converting to sql date ,but still i din't get any results
    java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
              String query1="select MTName,Date,MTLineCount from linecountdetails where mtname='"+MTName+"'  and Date >='"+fromDate+"' and Date <='"+tillDate+"' " ;
            System.out.println(query1);
    //From main method
    databaseConnection("prasu","1/12/2005","31/12/2005");I got the output as
    ---------- java ----------
    select MTName,Date,MTLineCount from linecountdetails where mtname='prasu'  and Date >='Thu Dec 01 00:00:00 GMT+05:30 2005' and Date <='Sat Dec 31 00:00:00 GMT+05:30 2005'
    java.lang.NullPointerException
    null
    null
    java.lang.NullPointerException
    Output completed (4 sec consumed) - Normal TerminationThanks
    Prasanna.B

  • Displaying Japanese characters in JSP page

    Hi,
    I am calling an application which returns Japanese characters from my JSP. I am getting the captions in Japanese characters from the application and I am able to display the Japanese captions. After displaying the Japanese captions, user will select the particular captions by selecting the check box against the caption and Press Save button. Then I am storing the captions in the javascript string separated by :: and passing it to another JSP.
    The acton JSP retrieves that string and split it by using tokenizer and store it in the database. When I retrieve it again from the database and display it, I am not able to see the Japanese characters, it is showing some other characters, may be characters encoded by ISO.
    My database is UTF-8 enabled and in my server I am setting the UTF-8 as default encoding. In my JSP pages also, I am setting the charset and encoding type as UTF-8.
    I shall appreciate you if you can help me in resolving the issue.

    Post the encoding-related statements from your JSPs - there are a number of different ones that may be relevant.
    It may also be relevant which database you store the strings in (Oracle, DB2, etc.), since some require an encoding parameter to be passed.

  • Display request contents in JSP page

    i need to display the contents in a request in my JSP.
    meaning:
    i have a hashmap (containing string and a list) coming from the EJB tier to struts action in an event response object, I'm sure that the request has these values. cuz i tested it in struts action using the following code:
    HashMap result = (HashMap)((EventResponseSupport)request.getAttribute(WebKeys.EVENT_RESPONSE)).getPayload();
    System.out.println("Sponsor name = " + result.get("sponsor"));I am able to print it in the console but i need to know how to display it in the jsp. i tried many things but i can't get it right.
    first i need to display the string and then i need to iterate through the list to display its contents in a table.
    any help would be appreciated.

    Kindly use JSP Scriplet to load the HashMap into the Page Context.
    Then you can use the Struts iterate tags to paint the contents of the HashMap

  • 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

  • Proble displaying images dynamically in jsp

    Hi, I am new here. I have to display the images dynamically reading from a database. I have no problem displaying images. When i try to reduce the width in img tag then it is slowly rendering it. How to overcome this.
    <img src="image.jsp?imgID=112" width="150" heigth="130" border="0">
    I am also giving the sample jsp to display
         byte [] imgData = blob.getBytes(1,(int)blob.length());
    response.setContentType("image/jpeg");
    OutputStream o = response.getOutputStream();
    o.write(imgData);
    I want to display the image without any time taken. How could I solve this. Please Help me.
    Thanks.
    Phani.

    You should not crosspost questions. It is rude and a waste of our time.
    Please stick to one topic: [http://forums.sun.com/thread.jspa?threadID=5372144].

  • Displaying arabic text in jsp page

    Hi,
    Iam displaying some arabic values which will come from server in my jsp page.
    but the problem when display the values its showing rubbish like �������������
    when i select the view-->encoding from browser its showing arabic values..
    i set <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> like this in my jsp page..
    When i put the arabic text in normal .html page its working fine its displaying fine..
    when iam calling jsp page iam getting above problem..
    do i need to make any setting in server..iam using j2ee refrence server..
    Regards,

    use UTF-8 for character encoding then arabic text will display

  • How to display unicode character in jsp pages?

    i have to display user need language using unicode character according to user selected in radio button arabic or german in jsp
    pages. can you explain how i have to code?

    Hi,
    Visit the following URL http://java.sun.com/docs/books/tutorial/i18n/ .
    It will help you.
    bye for now
    sat

  • Refresh display image item without reload page

    hi all, is a way to refresh (requery) a display image item to change the image via botton and do not reload page ?
    thanks
    Edited by: Reza.Gh. on Sep 24, 2012 11:56 AM

    I create a sample app :
    https://apex.oracle.com/pls/apex/f?p=9310:1
    code of item  P1_CAPTCHA_IMG :
    SELECT captcha_img FROM captcha WHERE response = :P1_CAP_V;
    item P1_CAP_V  code (computations) :
    SELECT *
    FROM (
    SELECT response
    FROM captcha
    ORDER BY
    dbms_random.value
    WHERE rownum = 1 ;
    Refresh botton code :
    action 1 :
    SELECT * into :P1_CAP_V
    FROM (
    SELECT response
    FROM captcha
    ORDER BY
    dbms_random.value
    WHERE rownum = 1;
    action 2:
    refresh item P1_CAPTCHA_IMG

  • Displaying html code in JSP page

    Hi.
    How do I display HTML code in an jsp page, so that the actual code is printet on the screen
    fx:
    <html>
    <head>
    </head>
    <body>
    </body>
    </html>

    I can't get my reply to show properly, but the answer is;
    Change < into &lt ; and > into &gt ;
    but with the semi-colons stuck next to the &lt and &gt if you get my drift

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

Maybe you are looking for

  • It is possible to change any warning message type to error message type?

    Dear All, Kindly do your need full efforts to solve this problem; For T code iw32, material avaibility checks works but it gives warning message as per error message required at this point. It is possible to change that message 281 i.e. Order & has m

  • ODI not reading XML file

    Hi All, Im working on implementing Oracle PIP with ODI. Im not able to access an XML file within ODI. The Physical architecture is set to the correct directory, filename etc. It was working fine before until recently we restarted the agent & re-encod

  • LV RT - String to double conversion

    Hello, I want to convert a string to a double on my Real Time device (PXI-8101. When I use the "scan value" or "Fract/Exp String To Number Function" VI the numbers after comma dissapear. This does not happen on the Host (PC).  So for example on the h

  • Can't update CC programs.  Stop at 42%

    Hi I am unable to update my apps on CC and have been for several months.  I contacted Adobe support several months ago and then just yesterday - and the issue still isn't resolved.  My programs that are old cc programs are on my computer but no longe

  • Forms Servlet IP Access

    Hi, I am tied to 9iAS R1 due to ERP app restriction - am using webcache 902 to balance 2 9iAS app servers using Forms 6i Listener Servlet. I am setting up SSL on webcache and intend to connect webcache to app servers on non-ssl port 80. I want users