Displaying Image In JSP for Mozilla Browser

Hai all
How to display the .gif image in JSP file using Mozilla browser

do you really think you give enougth information???
the answer to your question is using the html tag <img src='image_url'>

Similar Messages

  • Display image on jsp page

    I have to display image on jsp page with some text output. This image is already saved at a location parallel to web-inf and is generated dynamically using a servlet. I have used img tag html to display the image. Other outputs are taking their values from database.
    First problem is that image will be taking time to display in comparision of other outouts from database. I have to refresh the page to get imageon my page.
    Second is that if I save image in a folder parallel to web-inf in my project then it will not be displaying the image.
    Can I use any jsp functionality to display image with other outputs from database. I have used "*include*". but it shows only that image and other outputs.

    Best way is to use a servlet for this.
    <img src="path/to/imageservlet?id=someidentifier">
    <!-- or -->
    <img src="path/to/imageservlet/someidentifier">In the servlet's doGet() just write code which gets an InputStream of the image (either directly generated, or just read from the local disk file system, if necessary with help of ServletContext#getRealPath(), or even from the DB by ResultSet#getBinaryStream()) and writes it to the OutputStream of the response. That's basically all. Don't forget to buffer the streams properly to speedup performance and to save memory.
    You can find here a basic example: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Display image in JSP Portlet

    I create a JSP portlet. But The portlet can't display image(gif file, jpg file). I have modified the provider.xml and the following line is added:
    <imageURL>URL_Path</imageURL>
    But, the image still cannot be displayed.
    How can I display image in JSP portlet?

    Leo Cheung,
    You could try the following :
    1. Add a virtual directory path Alias 'imgf' in the Apache configuration file httpd.conf to load the image file. Add the following line under the alias section :
    Alias /imgf/ "<your directory>\images/"
    2. Place your gif/jpg files (eg., work.gif) in the images directory.
    3. Use the IMG tag of HTML :
    <IMG src="/imgf/work.gif" border=0 width=80 height=80> in the JSP file at the location where you need to display the image.
    Hope this helps
    Pushkala

  • Frameset bordercolor problem for mozilla browser

    Hi Every one,
    I am using frameset tag, when I use the below code it is working fine for IE browser but the bordercolor is not working for Mozilla browser. can any one help me for finding out the alternative for Mozilla browser.
    Thanks in Advance
    <html>
    <head>
    <title>Frame</title>
    <style>
    </style>
    </head>
    <frameset rows="40%,*" bordercolor=#ff0000 frameborder="yes" BORDER=10>
    <frame src="" name="listFrame" id="listFrame" frameborder="0" scrolling="no" marginwidth="2" marginheight="0">
    <frame src="" name="editFrame" id="editFrame" frameborder="0" scrolling="no" marginwidth="2" marginheight="0">
    </frameset>
    <noframes>
    <body>
    </body>
         </noframes>
    </html>

    This is a Java forum, not an HTML forum.

  • Problem for displaying image in jsp

    I like to retrieve and display image from database in jsp file. Now, image has been retrieved and store in session. But it cannot be displayed in jsp. Who can help me? Thanks a lot!
    Codes like below:
    <%
    byte[] b = (byte[])session.getAttribute("sessionName");
    System.out.println(b.length); //the length can be printed at console successfully
    if(b != null) {
    response.setContentType("image/*");
    OutputStream toClient=response.getOutputStream();
    toClient.write(b);
    toClient.flush();
    toClient.close();
    %>

    JSP is designed to return text/html documents.
    As such it automatically calls getWriter() to return a character stream. (places it in the implicit variable "out"
    Seeing as you want to return bytes, instead of character data, the JSP technology is not applicable
    Calling getOutputStream after getWriter has been called results in an IllegalStateException
    So calling getOutputStream in a JSP will ALWAYS throw an exception.
    Cheers,
    evnafets

  • Problem in displaying image on jsp page

    I want to display an image on jsp page.I copied the image the image in WebContent folder.
    I am able to see the image on the design pane when using the following code:-
    <img src="/image.gif" height="50" width="50"> but when i run it in the browser nothing gets diplsyed.
    also when i use the image container and select the source option that image is not displayed in the WebContents file..plz help.

    Hi,
    Seems that the Problem is there with the way how you specifuied the Image relative Path:
    You have specified the below: The opath of image starts with (/) forward slash:
    *<img src="/image.gif" height="50" width="50">*
    It means to access this Image WebLogic Container will form a Path like this:
    http://localhost:7001/image.gif
    BUT may be the image is available inside your Context root: So Change the <Img> tag like following in your JSP:
    *<img src="image.gif" height="50" width="50">*
    (*NOTE:* Never Start your src path with a Preceesing /)
    Now WLE will consider the path like below ..if your Applications Context root is "TestApp"
    http://localhost:7001/TestApp/image.gif
    I am Assuming that Inside the TestApp Application "image.gif" And "your.jsp" jSP pages are Co-Located (Means available in the Same Directory).
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Magical Stuff)

  • ADF BC:Displaying Image On JSP page

    Hai All
    I'm using ADF BC and JDev 10.1.3.
    I want to show an image on my jsp page from database.
    For this I have written an servlet with the following code
    response.setContentType("image/gif");
    OutputStream os = response.getOutputStream();
    String amDef = "package.AppModuleName";
    String config = "Configuration Name";
    ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);
    ViewObjectImpl vo =
    (ViewObjectImpl)am.findViewObject("ViewObject"); // get view object (the same as used in the table)
    System.out.println("vo:" + vo);
    vo.executeQuery();
    Row row = vo.first();
    BlobDomain image = (BlobDomain)row.getAttribute("field");
    //System.out.println("image:" + image);
    InputStream is = image.getInputStream();
    // copy blob to output
    byte[] buffer = new byte[10 * 1024];
    int nread;
    while ((nread = is.read(buffer)) != -1)
    os.write(buffer, 0, nread);
    os.close();
    Configuration.releaseRootApplicationModule(am, false);
    This servlet working perfectly.The image is displayed on the page while running
    the servlet alone.
    My problem is the image is not got displyed on the jsp page
    I tried following code to call the servlet
    <af:objectImage source="ImageServlet"/>
    <img src="ImageServlet" width="140px" height="50px" align="right">
    Where ImageServlet is the url-pattern in the web.xml for the servlet
    Both method are not working
    Any body please help me.......
    what I'm missing..............
    Is there any other way to display an image on JSP page using backing bean
    method.
    Thanks
    Ans

    HI,
    See: http://kuba.zilp.pl/?id=241
    Kuba

  • How to dynamically display images in JSPs

    This took a little while to figure out so I thought I'd share. After
              doing some research I was led to the following approach on how to load
              images from an Oracle database into a JSP:
              The "main" JSP:
              <HTML>
              <head>
              <title>Image Test</title>
              </head>
              <body>
              <center>
              hello
              <P>
              <img border=0 src="getImage.jsp?filename=2cents.GIF">
              <P>
              <img border=0 src="getImage.jsp?filename=dollar.gif">
              <P>
              world
              </body>
              </HTML>
              And this is the image getter:
              <% try {
              response.setContentType("image/gif");
              String filename = (String) request.getParameter("filename");
              java.sql.Connection conn =
              java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              connect to db
              java.sql.Statement stmt = conn.createStatement();
              String sql = "select image from testimage where filename = '" +
              filename + "'";
              java.sql.ResultSet rs = stmt.executeQuery(sql);
              if (rs.next()) {
              byte [] image = rs.getBytes(1);
              java.io.OutputStream os = response.getOutputStream();
              os.write(image);
              os.flush();
              os.close();
              conn.close();
              catch (Exception x) { System.out.println(x); }
              %>
              The thing to note is that there are no <%@ page import="..." %> or <%@
              page contentType="..." %> tags - just the single scriptlet. It
              seems that for every "<%@" the weblogic compiler sees it puts
              out.print("\r\n"); statements in the generated java source.(???) I
              don't know much about how browsers work but I think that once it sees
              flat ascii come at it it treats everything that follows as text/plain
              which is incorrect for the binary stream that's being sent. Another
              work around was to set out = null; but that's kind of ugly and might
              produce server errors. The real fix is to write a bean to handle images
              which I'll work on next (does anybody have any hints on how to do
              that?)
              -Erik.
              PS, thank you to the people that posted info in this group that helped
              me track down this problem. -
              

    Erik,
              No need to write a bean, just write a serverlet...
              you can use this function (however you might want to include some
              improved error handeling)
              Oh, FYI to prevent caching by the browser you might want to pass a parameter
              into the creation of the image like timeseconds or (in my case) variable
              text which
              was included into the image produced. (You need not even use the variable in
              the code, the server is not bright enough to tell)
              <IMG SRC=".....MyImageProducer?file=my.jpeg&timesecs=12345134">
              Jay L. Toops
              public boolean httpJpegStreamWriter(BufferedImage ib, HttpServletResponse
              response) {
              try {
              javax.servlet.ServletOutputStream myout = response.getOutputStream();
              byte b[] = new byte[1024];
              response.setContentType("image/jpeg");
              //File file = new File("./myserver/public_html", "testjlt.jpg");
              //FileOutputStream fos = new FileOutputStream(file);
              ByteArrayOutputStream fos = new ByteArrayOutputStream();
              JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(fos);
              JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(ib);
              param.setQuality(1.0f,false);
              encoder.setJPEGEncodeParam(param);
              encoder.encode(ib);
              b = fos.toByteArray();
              response.setContentLength(b.length);
              myout.write(b, 0, b.length);
              myout.flush();
              myout.close();
              } catch (Exception e) {
              System.out.println("MY httpJpegStreamWriter Exception\n is :"+
              e.toString());
              return(false);
              return(true);
              Erik Lindquist wrote:
              > This took a little while to figure out so I thought I'd share. After
              > doing some research I was led to the following approach on how to load
              > images from an Oracle database into a JSP:
              >
              > The "main" JSP:
              >
              > <HTML>
              > <head>
              > <title>Image Test</title>
              > </head>
              > <body>
              > <center>
              > hello
              > <P>
              > <img border=0 src="getImage.jsp?filename=2cents.GIF">
              > <P>
              > <img border=0 src="getImage.jsp?filename=dollar.gif">
              > <P>
              > world
              > </body>
              > </HTML>
              >
              > And this is the image getter:
              >
              > <% try {
              > response.setContentType("image/gif");
              > String filename = (String) request.getParameter("filename");
              > java.sql.Connection conn =
              > java.sql.DriverManager.getConnection("jdbc:weblogic:pool:orapool"); //
              > connect to db
              > java.sql.Statement stmt = conn.createStatement();
              > String sql = "select image from testimage where filename = '" +
              > filename + "'";
              > java.sql.ResultSet rs = stmt.executeQuery(sql);
              > if (rs.next()) {
              > byte [] image = rs.getBytes(1);
              > java.io.OutputStream os = response.getOutputStream();
              > os.write(image);
              > os.flush();
              > os.close();
              > }
              > conn.close();
              > }
              > catch (Exception x) { System.out.println(x); }
              > %>
              >
              > The thing to note is that there are no <%@ page import="..." %> or <%@
              > page contentType="..." %> tags - just the single scriptlet. It
              > seems that for every "<%@" the weblogic compiler sees it puts
              > out.print("\r\n"); statements in the generated java source.(???) I
              > don't know much about how browsers work but I think that once it sees
              > flat ascii come at it it treats everything that follows as text/plain
              > which is incorrect for the binary stream that's being sent. Another
              > work around was to set out = null; but that's kind of ugly and might
              > produce server errors. The real fix is to write a bean to handle images
              > which I'll work on next (does anybody have any hints on how to do
              > that?)
              >
              > -Erik.
              >
              > PS, thank you to the people that posted info in this group that helped
              > me track down this problem. -
              

  • How to display images in JSP

    Hi all,
    I created a Jsp page and I stored my images in the dist-->images folder and by using the following code
    <% String image = componentRequest.getWebResourcePath() + "/images/image.gif"; %>
    <img src="<%=image%>">
    I try to display the images in that page.
    Yes I am successful in displaying one image.
    But my problem here is to display more than two images which are present in that page.
    Can any body help me regarding this.
    Your help will be highly rewarded with points.
    Regards,
    Ramana.

    Hi Ramana,
    Set the image border to 1 and check atleast your borders get displayed. If it displays the border, then the problem may be with your image path.
    Before deploying for each modification in your JSP, check the preview of the page using "Preview" tab.
    Are you getting any exception?
    Check your whole JSP page once again (check all the scriplets).
    Regards,
    Uma
    Message was edited by: Uma Maheswari

  • Display image in jsp by retrieving it from DB2

    I insert image in to db2 table using the code given below
    PreparedStatement preparedStatement =
    connection.prepareStatement("INSERT INTO BOOKCOVERS VALUES(?,?)");
    File imageFile = new File("c:\\redbookcover.jpg");
    InputStream inputStream = new FileInputStream(imageFile);
    preparedStatement.setString(1," 0738425826");
    preparedStatement.setBinaryStream(2,inputStream,(int)(imageFile.length()));
    preparedStatement.executeUpdate();
    Now i need to retrieve the image and display in jsp page!!

    One way would be to write a Servlet... http://yourpage/ImageServlet/?id=0738425826
    Servlet:
    - get url parameter id
    - get the inputstream of the object from the db
    - read and directly write the data to the servletoutputstream
    regards
    slowfly

  • Display image in JSP

    Hi,
    I'm having problems allowing users to upload images within my j2ee application and then displaying them again. Does anybody have any tips?
    I don't really want to store the image in the db (just the image name), but I can't figure out where to put the image once it has been uploaded so that the JSP page can find it again.
    All of my current images are inside my .war file so I can't simply add the uploaded image to these. I'm using JBoss 4.0 if it matters....
    Your help is greatly appreciated,
    Stu.

    Hi.
    Probably not the best solution, but I've solved this by creating one war file that only holds images. It only has an empty jsp index file.
    I use a Unix workstation, so I've creted a symlink, (shortcut) from the folder I uppload images to, to the empty project. Then I can call the images from the jsp, and deploy new versions of my main application without the images....

  • Displaying Image in JSP page

    Hi there.. I have a problem with displaying an image from table with blob data type.
    Here's what have I done:
    I have this page to display an image from requestScope.test (I've set this value in data action).
    But the problem is, the image is only displayed once. Seems that after it read the eof of stream, It'll not move the pointer to the beginning. The image will show up again if view object retrieve new data from the database.
    Here's my code:
    ------------------------------------------------------begin of code----------------------------------------------------
    <%@ page import="java.io.InputStream,oracle.jbo.client.Configuration,oracle.jbo.ApplicationModule"%>
    <%
    response.setContentType("image/jpeg");
    response.addHeader("Content-Disposition","filename=img.jpg");
    InputStream sImage = ((oracle.jbo.domain.BlobDomain)request.getAttribute("test")).getInputStream();
    byte[] bytearray = new byte[4096];
    int size = 0;
    while((size=sImage.read(bytearray))!= -1 ){
    response.getOutputStream().write(bytearray,0,size);
    sImage.close();
    %>
    ------------------------------------------------------end of code----------------------------------------------------
    Any suggestion?
    Thx,
    Andre

    Sorry, I've just read the java doc for oracle.jbo.domain.BlobDomain and find method toByteArray(), and this method can solve my problem. Here's the new code:
    ----------------------------------------begin of code-----------------------------------------------
    <%
    response.setContentType("image/jpeg");
    response.addHeader("Content-Disposition","filename=img.jpg");
    byte[] bytearray = ((oracle.jbo.domain.BlobDomain)request.getAttribute("test")).toByteArray();
    response.getOutputStream().write(bytearray, 0, bytearray.length);
    %>
    ----------------------------------------begin of code-----------------------------------------------
    But I still intereset with the first solution, why it always find eof after it displayed. I've already closed the stream.
    Thx,
    Andre

  • Displaying image on jsp

    Hi,
    I am setting image byte array to servlet output stream after setting content type as "image/jpg".
    Problem 1:
    if I set contentType as "image/jpeg" or "image/gif" it is showing some image on page and for some image red cross mark comes in upper corner.
    Problem 2 :
    For "image/jpg", File Download window pops up and asks me for saving the file. I don't want to save it.
    Below is the sequence of code in my action class.
    response.resetBuffer();
    response.setContentType("image/jpeg");
    servletOutputStream.write(barray);
    servletOutputStream.flush();
    servletOutputStream.close();
    this image should be displayed on new opened window from where i have called above action.

    Problem 1:
    if I set contentType as "image/jpeg" or "image/gif" it is showing some image on page and for some image red cross mark comes in upper corner.Well, what is the correct contentType? You can't just set it on whim, it needs to be the correct type. Which is probably why the image that are actually that type show up, while others don't.
    Take a look at these to understand how to improve your code:
    - [http://balusc.blogspot.com/2007/04/imageservlet.html]
    - [http://www.exampledepot.com/egs/javax.servlet/GetImage.html]
    For example, you should set your content length.

  • JSP for mobile browser

    I was wondering wheather JSP can be use to write pages for mobile devices to be browsed. How do you do so?

    If the mobile device has a browser it doesn't matter.
    On the other side you would use wml for mobiles not cappable of rendering html.
    In that case you can use wml tags in your jsp, so the mobile renders the wml.
    NOKIA has excellent forums, tools and documentation.
    www.nokia.com
    I do not work there and I even do not like their mobiles, but the rest is excellent :-)
    Regards
    Tarik

  • Timer task (Time Schduling ) in JSP for hit/browse another site page

    Hi All ,
    I want to develope a JSP application which is run the perticular link in every 30 min.
    means i want to set the scheduling of 30 min which is browese(run) my another server link like http://nileshpatel.com/abc.jsp
    How can i do it OR Time Scheduling is possible in JSP?
    Thanks
    Nilesh Patel

    Yeah, I couldn't get it to work on the onLoad funtion either but it is probably a nested quote problem. Put it in a function and call that function from the onLoad event.
    <html>
    <head>
      <script type="text/javascript">
        function resubmit() {
          setTimeout("top.location.href='test.html'",3000);
          return true;
      </script>
    </head>
    <body onLoad="resubmit();">
    </body>Problems: This will only work if the user has the page with the above code opened when the 30min passes by. If they go to some other page, it won't work. If the user goes surfing around multiple pages with this code on it, the 30 minutes will be reset at each point the user gets to a new page.
    You are better off writing a normal Java application with a timer that runs as a service. Every 30 minutes it would trigger a browser to open the web page.

Maybe you are looking for