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)

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

  • 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

  • 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

  • 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

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

  • Problem in Retrieve Image from DB and display in the JSP page

    Hi All,
    I did one JSP Program for retriveing image from DB and display in the JSP Page. But when i run this i m getting "String Value" output. Here i have given my Program and the output. Please any one help to this issue.
    Database Used : MS Access
    DSN Name : image
    Table Name: image
    Image Format: bmp
    Output : 1973956
    Sample Program:_
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.io.*" %>
    <%
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              Connection conn = DriverManager.getConnection("jdbc:odbc:image");
              Statement st = conn.createStatement();
              ResultSet rs = st.executeQuery("SELECT images FROM image");
              String imgLen="";
              if(rs.next()){
                   imgLen = rs.getString(1);
                   out.println(imgLen.length());
              if(rs.next()){
                   int len = imgLen.length();
                   byte [] rb = new byte[len];
                   InputStream readImg = rs.getBinaryStream(1);
                   int index=readImg.read(rb, 0, len);
                   System.out.println("index"+index);
                   st.close();
                   response.reset();
                   response.setContentType("image/jpg");
                   response.getOutputStream().write(rb,0,len);
                   response.getOutputStream().flush();
         }catch(Exception ee){
              out.println(ee);
    %>
    Thanks,
    Senthilkumar S

    vishruta wrote:
    <%
    %>Using scriptlets is asking for trouble. Java code belongs in Java classes. Use a Servlet.
                   out.println(imgLen.length());Your JSP was supposed to write an image to the output and you wrote some irrelevant strings to the output before? This will corrupt the image. It's like opening the image in a text editor and adding some characters before to it.
                   byte [] rb = new byte[len];Memory hogging. Don't do that.
              out.println(ee);You should be throwing exceptions and at least printing its trace, not sending its toString() to the output.
    You may find this article useful to get an idea how this kind of stuff ought to work: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • Problem in displaying images

    Dear JSP/Servlet experts,
    I have problem in displaying images on a JSP page. I stored all the images names in a database and
    try to retrieve them based on the user selection. When the JSP page is load for the first time the
    following error occur but the images are displayed correctly:
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover150.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover154.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover152.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover151.jpg + null) Connection aborted by peer: socket write error
    2002-08-07 04:40:15 - Ctx( /simple ): IOException in: R( /simple + /images/cover156.jpg + null) Connection aborted by peer: socket write error
    Here is the code to display the images(the getCover() method will return cover150.jpg, cover151.jpg.... )
    and the images are stored in /simple/images folder
    <td><a href="<img src="/simple/images/<%= b.getCover() %>" alt="details"></td>

    try this
    <img src=/simple/images/<%=b.getCover() %>
    vasanth

  • Problem in displaying images stored in Blob variable

    Hi all,
    I have a requirement where i need to retrieve the image stored in Blob variable in DB and display the image in JSP page.
    I have written the below code to achieve this, it works fine
    In JSP, I am calling a action in the <img tag
    <img src='downloadPhoto.page?method=getPhotoInBytes&accessoryModelPictures.id.accessoryNumber=${photo.id.accessoryNumber}/> In my controller class
    InputStream inputStream=accessoryPicturesLOB.getPicture().getBinaryStream();
    byte[] theBytes = new byte[inputStream.available()];
    inputStream.read(theBytes);
    response.setContentType("image/jpg");
    response.getOutputStream().write(theBytes);But the problem is, *if i right click on the image and select save picture as option i get a error saying "The system cannot find the specified file "*
    Can you please tell me what is wrong in my approach/code
    Is there any better approach to display image that is store in Blob variable ?
    Please help on this.
    Thanks in advance.

    You need at least to set the filename in the content disposition header.

  • 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

  • Junk characters like" � � "displayed in the jsp page please help.

    Hi,
    I am getting junk characters like � � displayed in the jsp page.
    In the JSP page i used javascript "& nbsp" for appending spaces to a string "CCR" to get "CCR " .
    Now the Resultant string "CCR " has three spaces appended to its right.
    This String is set in session in that JSP page.
    In the next JSP page i am getting that string from session.
    After getting the string the "substring" function is performed to get only the first 5 charcters of the string. Now the result is displayed as " CCR� � " with has last 2 characters as junk values � � insteed of displaying as "CCR ". Please help me in solving this issue.
    Please note that initially the sting "CCR" is got from the Oracle database in Solaris Machine.
    Regards,
    Vijay

    have you tried:
    strenuously inspecting the string that is coming from the db? do an actual loop over the string, character by character, dumping to System.out to make sure the characters are EXACT coming out of the db.
    note you have to append " " not just "& nbsp"
    post the code that is doing the output. the relevant bean code, the jsp, everything relevant - WITH COMMENTS discussing where things are happening.
    Also, is it "weird characters" in the browser only? have you done a view source on the actual html source that the browser is rendering (right click in IE and click view source). browsers can act odd if you don't feed then exactly what they want, and it looks like you're feeding it escaped characters that it is rendering as something else.

  • Problem in displaying images one by one in JList

    I have a problem in displaying images one by one in Jlist. I want to show 100 images as a thumbnailview in jlist but it is talking too much time to show all the images after scalling 100 images to thumbnail view and making it into ImageIcon. So, i thought that it would be better way to show one by one after scaling it into thumnailview. But my renderer is getting calling after 100 images scaled down and setting into list. I have posted my code 2 days back but there is no reply.
    http://forum.java.sun.com/thread.jspa?threadID=789943
    I donno where i am missing in this code.
    Plz suggest me some solution for it.

    Where is the scaling done? In the ListCellRenderer? Regardless of where that is being done, I assume you are caching the scaled images after you scale them, right? If not, consider adding some sort of caching.
    This should do the trick...
    Rework your ListCellRenderer to check to see if a scaled version of the image is available. If not, start a thread to do the scaling and create an ImageIcon. In the meantime, while that thread is running, have the renderer return some sort of stock icon, like a little generic image icon. When the scaling thread completes, make a call to repaint() on the JList so the cell renderer gets re-asked for the icons. This time around, the renderer should notice that a scaled version (the ImageIcon) is available. Return that. So, this method doesn't guarantee that the images will be produced in order, 1...2...3..., but it will return images as they become available, and the overall JList rendering won't wait until all 100 are ready. If you want them returned in order, just do all of the scaling in a single thread and queue up the images to be scaled, in order.
    I hoped this helps. (If it does, please throw me some Duke Dollars.)

  • Problem in displaying total no of pages in Smartform

    Hello experts,
    I have a problem while displaying total no of pages in Smartform.
    When no of pages are more than 10 then in total no of pages , a * is shown till current page is 9, then after it is displaying correct no of pages.
    I am using &sfsy-formpages& to get total no of pages.
    Ex: Like if I have 12 pages to print then i am getting 1/, 2/, 3/* .......... 9/* then 10/12 , 11/12, 12/12.
    Do i have to write some code for that ?? Please give your inputs to get the total no of pages.
    Thanks !

    Hi,
    Try this.
    Page &SFSY-PAGE& of &SFSY-FORMPAGES(4ZC)&
    Thanks,
    Anitha A

  • Problem with displaying image

    Hello!
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.
    Thnks a lot.

    1009316 wrote:
    Hello! Welcome to the forum: please read the FAQ and forum sticky threads (if you haven't done so already), and update your forum profile with a real handle instead of "1009316".
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    Sorry, I'm a beginner in APEX and have some problems with displaying images in my application. I have read the same topic but unfortunately didnt find the solution.
    So.. I have the interactive report
    table test (
    NAME NOT NULL VARCHAR2(4000)
    ID NUMBER
    BLOB_CONTENT BLOB
    MIME_TYPE VARCHAR2(4000))
    I need to display the column blob_content.This is described in the documentation: About BLOB Support in Forms and Reports and Display Image. There's an OBE tutorial that followed the introduction of declarative BLOB support in 3.1 as well.

  • I have selected not to load images automatically in OPTION of firefox, and i want to keep this option as it is. now can i display images of particular page without changing DONT LOAD IMAGE AUTOMATICALLY?

    i have selected not to load images automatically in OPTION of firefox, and i want to keep this option as it is. now can i display images of particular page without changing DONT LOAD IMAGE AUTOMATICALLY? for example if i trust that image on particular page doesnot contain any adult material and safe to see that page from home, can i temparory view image on page?

    -> Tap '''ALT''' key or press '''F10''' to show the Menu Bar
    -> go to Tools Menu -> Options -> Content -> click '''Exceptions...''' button infront of '''Load images automatically''' -> type the address of the website on which you want to load images e.g. yahoo.com and click '''Allow''' button -> click Close
    -> Click OK on Options window -> Restart Firefox
    Check and tell if its working.

Maybe you are looking for

  • Database Performance: Large execution time.

    Hi, I have TPC-h database of size 1GB. I am running a nested query having multiple joins between 5 tables and a group by and order by on three attributes. It took around 1 hour for this query to get executed (also it was fired for the point which can

  • Photoshop CS2 issue after 0.4.6 update

    I used software update to install the 10.4.6 update. was running 10.4.5 before that. Photoshop now crashes after I save tifs/psds/dcs's. If i use save for web, it does not crash. The files that are saving when it crashes seem okay (good thing!) but i

  • Problem with Require Client Certificate on on IPlanet 6.0 server

    I installed client certificate. When I connect to the server using browser, I get following error........ You are not authorized to view this page You might not have permission to view this directory or page using the credentials you supplied. How ca

  • Using App Store in China

    I recently bought an iPad thru the Chinese Apple website. When I try to buy apps in the App Store, I get a bubble saying I'm not allowed to do this; I must enter thru the US Apple website. However, even if I start in the US website, as soon as I hit

  • 10.6.5 install error (blue screen w/spinnig wheel)

    I just tried to update mac os x through software update. The macbook pro restarted ritght aay and then I when to lunch. About 1 hour later i came back and the only thing I see is a blue screen with the spinning wheel goin and going and going.. (not t