Dynamically output image in JSP?

Hi,
This is a fairly simple action in VBScript, but I can't get it working here in JSP.
For a database db, i want to cycle through db rows and read the information, and depending on the information in db, different images are populated.
so far i tried to just dynamically printing out images by wrap <jsp:scriptlet> or just <script> around the <ui:image> but it keeps on giving me errors.
Could someone please point out the obvious thing that i am missing?
And how would I iterate through the database rows in jsp?
appreciate you help.

I display images dynamically in my application based on Spring and using JSC. Take a look at this tutorial to see what I did: http://swforum.sun.com/jive/thread.jspa?threadID=52657&tstart=0
In short, I use servlets to read the data, and then set that to the button's image properties. There is a trick to it mentioned in the tutorial I believe).

Similar Messages

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

  • Dynamic images with JSP

    Hello,
    I am using NetBeans to make a WebApp. I have an image to display on Page3.jsp that is generated during the navigation from the previous page, Page2.jsp. This image is a png file, and is unique graph generated for each visitor. Is there a simple way to display dynamically created images? I have searched for tutorials and asked my good pal Google but to no avail.
    (FYI: At present, I am saving the images in a folder I have created beneath the 'web' folder, called 'web/images'. Netbeans asks me if I want to reload the image only after the previous, old image has been sent out by the server. I am producing and creating the image with the button_action method of Page2.jsp that then sends the user to Page3.jsp, where the image is to be displayed. Once the image is reloaded, I can refresh the web page and the correct image appears.)
    Any help would be greatly appreciated.
    Thanks,
    Taivo

    Although I have never implemented this, I know it is possible and I can point you in the right direction. If you already have the code to create the .png image, it shouldn't be too difficult to modify the image code into a servlet to serve nothing but the image (and leave rest of the html in place). Just as the page is writen to an output stream from the request for page.jsp (by the servlet created by the jsp parser), a request for an image can be handled by a servlet.
    //this is in page3.jsp as plain HTML
    <img src="/servlet/graph?user=aUser" />This servlet (graph.class) draws ths image, but instead of writing it to a file, writes it to the response stream.
    Hope this helps,
    Bamkin

  • Dynamically output a  image via struts insted of servlet

    Hello,
    I want to know how to dynamically output a image via struts insted of servlet;
    I can work it fine with the serverlet, this how i get it to work via serverlet:
    java class:
    public class ImageServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
    in web.xml :
    <servlet>
    <servlet-name>ImageServlet</servlet-name>
    <servlet-class>com.admin.transferform.ImageServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ImageServlet</servlet-name>
    <url-pattern>/ImgServlet</url-pattern>
    </servlet-mapping>
    and access the pic in[b] jsp :
    <img src="/ImgServlet"></img>
    <br>
    I just want to know, how do i access via struct?
    i change the java class to :
    public class ImageServlet extends Action {
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
    and in struts-config.xml :
    <action
    path="/image"
    type="com.admin.transferform.ImageServlet">
    </action>
    and i have tryed both these in jsp but none did work:
    in JSP :
    <img src="/image"></img>
    or
    <html:image src="/image" />
    can some one tell me, where did i went wrong pleaseee :)

    ImageServlet java :
    package com.admin.transferform;
    import java.io.*;
    import java.net.URLConnection;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    import org.apache.log4j.Logger;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionError;
    import org.apache.struts.action.ActionErrors;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    public class ImageServlet extends Action {
         private static Logger logger = Logger.getLogger(ImageServlet.class);
    public ActionForward execute(ActionMapping mapping, ActionForm form,
    HttpServletRequest request, HttpServletResponse response) {
              try {
                   InputStream in = new BufferedInputStream(new FileInputStream("/export/projects/images/headernews.jpg"));
                   logger.debug("dec : trying to output the image file");
                   String s = URLConnection.guessContentTypeFromStream(in);
                   response.setContentType( s );
                   byte pic[]= new byte[in.available()];
                   in.read( pic );
                   OutputStream out = response.getOutputStream();
                   out.write( pic );
              } catch (IOException e) {
                   logger.error("Error opening file region", e);
              return null;
    in struts-config :
    <action-mappings>
    <action
    path="/image"
    type="com.waterfind.admin.transferform.ImageServlet">
    </action>
    </action-mappings>
    jsp :
    <img src="<html:rewrite action="/image"/>">
    or
    <img src="/myContext/image.do"/>
    none working still, any more help please :)

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

  • Handling dynamically generated Images

    Hello,
    I have a WDJ application that generates Images dynamically based on certain criterion. The dynamically generated images are put to the server using the code
      BufferedImage image = <rendered image ...>
      File outFile = new File( "Output.jpg") ;
      ImageIO.write( image, "jpg", outFile);
      /** Resource path is not set during the file creation 
       * as ImageIO throws IllegalArgumentException
    It gets saved to the folder <i><drive>\usr\sap\<SID>\JC<InstNo>\j2ee\cluster\server0\output.jpg </i> by default.
    Now, how to show up this dynamically generated image in a Image UI element? I have tried setting the output file name to the attribute that is bound to the "Source" property of the Image UI element but it doosn't show up as WD runtime is doing a look-up in the folder <i>../../../resources/com.test/<projectName>/Components/com.test.<componentName>/</i>
    Any pointers in this regard are highly appreciated.
    Bala

    Hi
    Try this
    Create the alias for the folder (C:\usr\sap\P13\JC00\j2ee\cluster\server0.)
    1.Goto Visual Administrator->Http Provider->Aliases in the Runtime Tab.
    2.Give the Alias Name and Path for the Folder.
    3.The Image sorce like http://<Server>:<Port>/<Alias>/<image>.<ext>
    Kind Regards
    Mukesh

  • Capturing the output of a jsp page and save that output in a WORD .doc file

    Hi,
    This is Naveen. I got stuck up with a problem/doubt. URGENT ! URGENT !
    My doubt is how to capture the output of a jsp page(the content is dynamic generated) and save that output to a MS-Word doc file.
    I know that therez an option of using Servlets Filters, but this concept is supported by Servlet 2.3 spec. and not earlier. And we are working on previous spec. and our web-servers also supports the prev. version and not the 2.3 version.
    If incase, therez a third-party utility for free usage, suggestions are appreciated.
    Hope most of them came across this kind of functional requirement. If anyone of them succeeded in this, please express ur bitter experience if any, faced during the coding.
    Thanks in Advance for help.
    Naveen

    You can set the MIME content type as .doc and try to open the Page.
    res.setContentType("application/vnd.ms-excel"); to generate the Page output as Excel
    res.setContentType("application/vnd.ms-word"); to generate the Page output as MS Word doc
    Hope this helps..

  • Display Base64Encoder string(barcode) as image in jsp/email

    Hi,
    I am trying to display the barcode image in jsp from the Base64Encoder encoded string.
    Earlier i tried to set the output stream of barcode image in the response of the HttpServlet. However, this is not working when i view in the mobile device android/iphone.
    Now when i use this Base64Encoder, the string which i am passing to the email template(jsp page), i cant able to view the image when i view in the email(outlook).
    But when open this outlook content(.mht) in browser(IE 8), able to see the image. Also when forward this email to the android/iphone mobile device, able to see the image.
    The barcode image is not displayed only when i open the email directly in the outlook/browser.
    Please help me to resolve this issue.

    Hi Gopi,
    Thanks for your reply.
    when i open the email in outlook, i am getting 'If there are problems with how this message is displayed, click here to view in a web browser'. So when i view in browser(IE) on clikc of this link, the email opened from the temporary internet files(AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\54AMMRVF\email (4).mht)
    Here i am able to see the image.
    Suppose if i forward this email to my gmail and opening in a browser, this time i cant see the image. i am getting only the blank space there.

  • How to display  servlet dynamically generated image ?

    Hi,
    How to display servlet dynamically generated image ?
    I have a servlet generating a buffered image in the doGet. I want to display the image in a jsp page with other information. I'm not able to get it properly displayed.
    **Try n# 1 **************************************************************
    This displays my image but nothing elle :
    ServletOutputStream sos = pResponse.getOutputStream();
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(sos);
    encoder.encode(img);
    **Try n# 2 ****************************************************************
    I tried also :
    In the servlet :
         request.setAttribute("renderedImage", img);
    and in the jsp page :
         BufferedImage image = (BufferedImage) request.getAttribute("renderedImage");
         <img src="<%=ImageIO.write(image,"jpeg",response.getOutputStream())%>" width="300" height="280"/>
    This last try draws big crap in the jsp page, thank you in advance.
    Nelson

    Call another servlet from the IMG tag. Have the servlet stream out the image using ImageIO (instead of writing HTML).

  • Dynamic Photo Album using JSP

    Hi all,
    I've been having a bit of trouble getting help with my question - I've tried a couple of usenet groups, however don't seem to be asking the right question. So, I'm hoping that some Java forums may be of more relevance. I'm sorry if this is the wrong place, and if there is a better place for me to ask my question if you could tell me where that is, I'ld be greatful.
    I am looking at finding/ making an online dynamic photo album which
    uses JSP. I've seen a lot of examples using PHP and a few online
    albums using Javascript, however those albums using JavaScript are not
    dynamic - the images are hard coded.
    My scenario is this, we have about 6 different events with about 150
    photos each. What I would like to happen is to be able to have a index
    page which lists 10 photos each, and when you click on the photo to be
    taken to a secondary page with a larger image. I would like to do this
    without needing to create 150 dependant pages.
    I understand that we will be looking at using server side technology.
    As our pages already use JSP we don't want to add a second server side
    language (PHP, Pearl etc...) to the equation.
    So does anyone know of a script that may already do this? As I seem to be having no luck in finding one to suit my purpose, I would be happy to create my own script.
    The problem is that I am not too familiar with JSP - though I used to do a fair bit of ASP using VB Script. What I would like is to be pointed into a page that will show me how to create an array with a list of filenames in a given directory (using a Site relative path). From there I should be right, but I can't seem to find any references to how this can be done using JSP (or even Javascript).
    If anyone can help me I would greatly appreciate it.
    Regards
    Linda

    You need to File class, it can produce a list of files in a directory.
    File photodir = new File("c:/path/to/photos");
    File[] photos = photodir.listFiles();
    for(int i = 0; i < photos.length; i++){
    File fp = photos;
    if(fp.isFile()){
    // check to see if it is an image

  • 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

  • Problem to output image using ServletOutputStream

    Hallo everybody! Can anybody help me? I try to output image (jpeg) using ServletOutputStream. First I upload jpeg image to server disassemble it to binary data and save to database binary data, image length, and image type. Then I try to output image.
    Here the code:
    response.reset();
    response.setContentType(strContentType);
    ServletOutputStream sos=response.getOutputStream();
    sos.write(buf,0,bflen);
    sos.close();
    variable buf is array of byte with binary data
    bflen is image length
    strContentType it image type (image/pjpeg)
    I use JRun server 3.1
    I tried to save an image file:
    FileOutputStream fos = new FileOutputStream("test_logo.jpg");
    fos.write(buf,0,bflen);
    fos.close();
    And I got an jpeg file.

    I've done the exact same thing... almost. I have a
    servlet that sends a jpeg file to an applet for
    processing. Anyway, I did two things differently.
    First I used the write(byte[]) rather than
    write(byte[], int offset, int length). If you're
    going to send the whole array anyway, don't bother
    with the other parameters.
    Second, I call flush() on the output stream before I
    close it. I have a feeling this is why. Remember,
    web connections are connectionless. You don't know if
    the data was send or received. I assume what is
    happening is that you try to send the data then close
    the connection right away and the data may not get to
    the destination.
    Here's what I have. I don't think the content type
    really matters but I know multipart/form-data is
    binary.
    response.setContentType("multipart/form-data");
    response.getOutputStream().write(image.data);
    response.getOutputStream().flush();
    response.getOutputStream().close();
    I'll try it. But I have problem to call getOutputStream() method. It produce IllegalStateExeption. I think that because implicit getWriter() method calls. (I use JSP)
    Do you know how to reset somehow response to have ability to call getOutputStream()?

  • Can't create dynamic html elements with jsp????? important

    Hi All,
    I am having problem creating dynamic html elements with jsp tags, i have tried to use EL and java scriplet, both of them don't work.
    i am trying to create dynamic menu in my "rightMenu.jspf", based on, if user has logged in or not.
    some like this!
    <jsp:if test ="${validUser == null}">
    some simple text menu here
    </jsp:if>
    but it is not working. it simply loading all and images with in statement, regardless of whether user has logged in or not. i think some how if statement is not working properly.
    "validUser" is a session bean, which is not creating at this point, it will created when user will log in successfully. and also this session bean does not exist at the page, where i am trying to check that .
    Is there any way to create dynamic values in jsp. It is really important, is there any body who help me in this matter. i would be really grateful.
    zaman

    hi jaspre,
    thanks for replying me. you know what, is it not something wrong with web.xml file. i remember once, i deleted some from there, a property with "*.jsp". i can't remember what exactly was it though.
    all if statements works on files ending with extension ".jsp" but don't work only on with extension ".jspf". there must be to do with 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>ValidateServlet</servlet-name>
    <servlet-class>ValidateServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ValidateServlet</servlet-name>
    <url-pattern>/ValidateServlet</url-pattern>
    </servlet-mapping>
    <servlet>
    <servlet-name>dwr-invoker</servlet-name>
    <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>pollAndCometEnabled</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>dwr-invoker</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    main.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    if any one can figure it out. i would be grateful.
    zaman

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

  • 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

Maybe you are looking for