Problem in dispalying the image !!!!

Here i'm reading the contents of the file and displaying the image in the jsp as well as the contents of the file. For displaying the image i'm retrieving the image from the file. I've written the following code but it is showing the error, i'm not able to catch it. Could anyone help me out please !!!!
File ff3 = new File(tmp,"pictureData.jpg");
String sss = String.valueOf(ff3.getName().replaceAll("\\","/"));                       
                        //sss.replaceAll("\\","/");
                        out.write("<td>"); 
                        %><img src="<%= sss%>"><%
                        out.write("</td>");in advance thanks.....

Why cant u try like this
<%@ page import="java.io.File"%>
<html>
<title>Image Display</title>
<body>
<table border="1">
<%
File f = new File("image.jpg");
out.println("<tr><td>f.getName() = " + f.getName() + "</td></tr>");
out.println("<tr><td><img src='image.jpg'></td></tr>");
%>
</table>
</body>
</html>Cheers

Similar Messages

  • Problem in saving the image into SQL database..

    Hello,
    In my application I have to save image file (say jpg) into the database and retrieve back and display it on the applet. I am through with grabbing the pixels of the image & sending the pixel array to the servlet but I am struck in how to store the image into the database and retrieve the same.
    Can anybody please help me in this regard... its really urgent...
    Thanks in advance
    Swarna

    Hello.
    I've been researching this problem (saving images in a MySQL database) in order to accomplish a task I was assigned to. Finally I was able to do it. I'd be glad if it will be of any use.
    First of all: the original question was related to an applet. So, the post from rkippen should be read. It says almost everything, leaving the code job for us. Since I managed to write some code, I'll put it here, but I'm not dealing with the byte transferring issue.
    To obtain a byte array from a file I'd open the file with FileInputStream and use a loop to read bytes from it and save them into a ByteArrayOutputStream object. The ByteArrayOutputStream class has a method named �toByteArray()� which returns an array of bytes (byte [] b = baos.toByteArray()) that can be transferred in a socket connection, as said by rkippen.
    My problem was to save an image captured by a web camera. I had an Image object, which I converted into a byte array and saved into the database. Eventually I had to read the image and show it to the user.
    The table in the MySQL database could be:
    CREATE TABLE  test (
      id int(11) NOT NULL auto_increment,
      img blob NOT NULL,
      PRIMARY KEY  (id)
    )I had problems trying to use the �setBlob� and �getBlob� methods in the Statement object, so I used the �setBytes� and �getBytes� methods . In the end, I liked these methods most because they where more suitable to my application.
    The database operations are:
        public int insertImage(Image image) throws SQLException {
            int id = -1;
            String sql = "insert into test (img) values (?)\n";
            PreparedStatement ps = this.getStatement(sql);  // this method is trivial
            byte [] bytes = this.getBytes(imagem); // * see below
            ps.setBytes(1, bytes);
            ps.executeUpdate();
            id = ps.getGeneratedKeys().getInt(0); //Actually I couldn't make this line work yet.
            return id;
        public Image selectImage(int id) throws SQLException {
            Image img = null;
            String sql = "select img from test where id = ?\n";
            PreparedStatement ps = getStatement(sql);
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) {
                byte [] bytes = rs.getBytes(1);
                img = this.getImage(bytes); // * see below
            return img;
        }* If the bytes are read directly from a file, I think it is not necessary to convert it into an Image. Just send the bytes to the database method would work. On the other hand, if the image read form the DB will be written directly into files, the bytes obtained from rs.getBytes(1) would be enough.
    The image operations are:
        public byte [] getBytes(Image image) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ImageIO.write(this.getBufferedImage(image), "JPEG", baos);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return baos.toByteArray();
        public Image getImage(byte [] bytes)  {
            Image image = null;
            ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
            try {
                image = ImageIO.read(bais);
            } catch (IOException ex) {
                throw new RuntimeException(ex);
            return image;
        public BufferedImage getBufferedImage(Image image) {
            int width = image.getWidth(null);
            int height = image.getHeight(null);
            BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
            Graphics2D g2d = bi.createGraphics();
            g2d.drawImage(image, 0, 0, null);
            return bi;
        }That's it. I hope it is useful.

  • Problem in getting the image through URL

    hi all,
    I facing the problem,Inwhich i am unable find the solution...I am using the following code to display the image
    public void doGet(HttpServletRequest request,HttpServletResponse response)
                        throws IOException, ServletException {
                   int data=0;
                   response.setContentType("image/png");
                   ServletOutputStream out = response.getOutputStream();
                   String file = request.getContextPath()+imageNames[0];
                   //String file = "C:/Program Files/Apache Group/Tomcat 4.1/webapps/ImageComm/WEB-INF/images"+imageNames[index];
                   BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
                   System.out.println("the size of the inputStream is..."+in.available());
                   System.out.println("the context path is..."+request.getContextPath());          
                   while ((data = in.read()) != -1) {
                   out.write(data);
    with the above i am not getting any error at the compile time but it was giving exception like FileNotFoundException.
    but the same thing(URL address) when i am copying on the browser it was displayig the image.
    (what might be the reason)
    one more thing when i commented on the url address and try to use the actual realpath address it was displaying the image with out any problem
    can anybody give me the solution like where to keep my images by which i can able to get the images through url address
    thanks in advance
    lakshman

    hi all,
    I am getting the image from the server.but the problem is i am getting the Exception as ArrayOutOfBound exception.
    It was displaying the Image for the first time.and when ever it was going for the second time in to the paint method it was displaying the IOException in reading the stream from the connection.
    can anybody give me the solution in rectifying that exception.
    thanks in advance
    lakshman

  • I have a 27" Viewsonic 1080p monitor connected to an oldish Mac Pro with an ATI Radeon X1900 XT Graphics card.  The problem is that the image does not fill the screen?!?!?

    I know the image can fill the monitor, because at start up, the white Apple logo screen fills it up.  But once the system starts up, there are bands of black framing the image.  I have searched extensively on the internet and found the following clues, none of which solved the problem:
    1) In the Windows world you can get software from ATI called Catalyst Converter that gives you the cpaobility to scale the image.  This software/feature is not available for Mac users.
    2)  Viewsonic's web site has a trouble shooting tool.  This came up in response to the topic "you have recently upgraded to a larger monitor"
         "This could be an issue if you have an older Apple using the system's onboard memory to support both the system and video display. Even if you have enough onboard RAM to support a higher resolution, it will not since the system will use some of the memory. Because the true video RAM available is much smaller than the total onboard amount, the system limits the size of the image. You will need to contact Apple to get an upgrade in onboard RAM or update the complete system."
    I have 2GB of RAM, so lack of RAM memory does not seem to be an issue. I am running OS 10.6.8
    Does anyone have any clue how to solve this problem.  It is frustrating to have a 27" monitor behaving like a 25" monitor. 
    Thanks in advance for sharing any experience on this.
    JD in PA

    http://www.xlr8yourmac.com/Graphics/radeon_X1900XT/X1900XT_dust_buildup.html#sto rytop
    http://www.xlr8yourmac.com/Graphics/X1900XT_Overheating/ATI_X1900_artifacts.html
    http://www.amazon.com/BUFFERED-PC2-5300-FB-DIMM-APPLE-Memory/dp/B002ORUUAC/
    http://www.amazon.com/Apple-ATI-Radeon-5770-MC742ZM/dp/B003Z6QH6M/
    http://www.amazon.com/PCIe-Power-Cable-nVidia-Video/dp/B002UR1654/
    http://www.amazon.com/gp/product/B0036Q7MV0/

  • Problem in dispalying the line no in particular format in the table footer

    Hi,
    i am facing a problem in dispalying line numbers in a particular format (expalined below) in the table view control(footer of table) of a RSS iView. The format is
    X - Y / Z
    where:
    X refers to the number of the top article/link displayed
    Y refers to the number of the lowest article/link displayed
    Z refers to the total number of articles supplied by the news-feed.
    i am able to dispaly line number in format X/Z, if someone have some idea please reply.
    Thanks in advance

    Hi Deepak,
    see Table View for the same question.
    Hope it helps
    Detlev
    PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

  • Problem in getting the image coordinates  when i zoom in or zoom out

    Hi,
    i have doubts with scaling (Zoom in and Zoom out) using following code but when i zoom in want to get the x and y coordinates but im getting resized coordinates , pls do the needful
    public class TiffTest extends JFrame implements MouseListener
    public TiffTest(String filename)
    RenderedImage source= JAI.create("fileload",filename);
    SubsampleBinaryToGrayDescriptor sb=new SubsampleBinaryToGrayDescriptor();
    RenderingHints rh=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_DEFAULT);
    RenderedOp op=sb.create(source,new Float(0.5),new Float(0.5),rh);
    JScrollPane scrollPane = new JScrollPane();
    displayjai dj=new displayjai(op);
    scrollPane.setViewportView(dj);
    getContentPane().add(scrollPane,BorderLayout.CENTER);
    int screen_width=(int)this.getToolkit().getScreenSize().getWidth();
    int screen_height=(int)this.getToolkit().getScreenSize().getHeight();
    setVisible(true);
    setSize(screen_width,screen_height);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    dj.addMouseListener(this);
    JAI.create("filestore",dj.ima,"god.tif","TIFF");
    public static void main(String s[])
    new TiffTest("1_org.tif");
    public void mouseClicked(MouseEvent e){System.out.println(e.getX()+","+e.getY());}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseExited(MouseEvent e){}
    class displayjai extends DisplayJAI
    RenderedOp ima;
    public displayjai(RenderedOp inputImage)
    super(inputImage);
    ima=inputImage;
    setPreferredSize(new Dimension(ima.getWidth(),ima.getHeight()));
    System.out.println(inputImage.getWidth()+","+inputImage.getHeight());
    Thankx
    Kannan

    hi all,
    I am getting the image from the server.but the problem is i am getting the Exception as ArrayOutOfBound exception.
    It was displaying the Image for the first time.and when ever it was going for the second time in to the paint method it was displaying the IOException in reading the stream from the connection.
    can anybody give me the solution in rectifying that exception.
    thanks in advance
    lakshman

  • Execute Query problem in viewing the Image

    Hi all,
    I've created a table with the following command
    Create table test (id Number(5),img_File Blob);
    Now i've created a form, where in the I've placed two fields (id and Img_File). The data type for the Img_File field is Image Item. I'm able to see that it is getting saved.
    I've seen it using the toad that the data is being inserted into the table. When i try to press f7 and then f8(i.e.., Enter Quey, Execute Query). I'm getting the following error.
    ORA-00932: inconsistent datatypes: expected got
    My block is based on the table. I'm using Forms 6i, Windows XP. My doubt is why the error is not showing the datatype (for Ex. Expected Number got date).
    If any one has worked on the Blob, then can suggest me.
    Regards,
    Alok Dubey

    Hi,
    Thanks for your replies. I've used Long Raw data type for the image column. it started get queying.
    i've a doubt that whether it is same in Forms 6i and Forms 10g also(i.e.., Both the versions use the Long for the images). As BLob has more advantages than
    the Long raw. As this is the Oracle recommendation, I want to use Blob. Is there any work around to it.
    Regards,
    Alok Dubey

  • Problem in viewing the Image in BLOB

    Hi,
    I am using the Toad 8.0. I have one problem, I inserted approx 2.5 million records in one table say V_Images using the SQL Loader, there are few records in Table where image is not loaded properly. Approx 99% is done only 1% is having wrong data, We want to identify and delete that, where no image is loaded. Is there any function or method to check those records which doesnt have Image.
    Please let me know,
    Thanks in adv.

    You can probably check the Length of the BLOB column.

  • Photoshop problem (not showing the image)

    hy,
    i just installed photoshop on my new laptop and it does not show any images when i open them.
    like you can see in teh image that i posted i have a picture opened (its also so in a layer)
    i can use photoshop but i dont see anyting changing in the normal area( is does change in the layer box.)
    i tried with different pictures
    pleas help

    Chris Cox wrote:
    And my money would be on a video card driver that needs to be updated. Disabling OpenGL drawing should avoid the issue temporarily, but the bug is in the video card driver.  (we've seen this a lot with older drivers)
    where can i find the disabling OpenGL Drawing?
         i have a NVIDIA GeForce GT 540M
    My money is on your document window being off screen. 
    At some point you may have had a secondary monitor attached which you have since disconnected, or you drastically changed your monitor resolution.
    Trashing your preferences should fix it instantly:
    To re-create the preferences files for Photoshop, start the application while holding down Ctrl+Alt+Shift (Windows) or Command+Option+Shift (Mac OS). Then, click Yes to the message, "Delete the Adobe Photoshop Settings file?"
    i tried this but i did not work. (however i do work with diferent screens)
    thanks already for you efforts

  • I want to implement the image in my report

    Hi
    I am replicating some of the sample report  of SQL Servers in BusinessObjects XI R3.1.
    One of the SQL Sever's report is of product catalogue type that gives complete information like name, category, description along with the products image etc... for each of the products.
    I am trying to replicate the above said SQL Server report in Business objects XI R3.1. I am facing problem in bringing the image in to my BO report. The image resides in a table and its datatype is of varbinary(max). I don't know the exact matching while creating an object in the uiverse designer.
    Here is the url link [http://errorsbusinessobjectsxir3.blogspot.com/2010/10/business-objects-image-errors.html]
    Please, help me out in those above said issues.
    Regards, Prasad
    Edited by: prasadboxir3 on Oct 8, 2010 10:44 AM

    Insert Free standing cell in report from Templates tab.
    In that Cell place your Image URL or Point the image. Then It will show the Image where ever you want.
    Thank You!!

  • Make the link from the single cell of Bex Report and the image of bill

    Hi guys,
    my client scan every bill and archive the image by File.net technology.
    In our Bex Report we have the Bill number and we want to make the link from the single cell and the image of bill.
    The possible paths to solve the problem are:
           Replicate the image in BW and crate a link from the single cell and the image of document.
           Create an URL link from the single cell and the image of document archived on File.net server.
    In witch way we can to implement the two paths?
    Thank you.
    Alessandro

    Hi Alessandro,
    Have you seen "How To…Enhance your Web Query with the Table Interface"?
    You can find it in media library:
    https://websmp105.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000194044
    Best regards,
    Eugene

  • How to view the image as cylindrical view in panorama image viewer?

    i am facing the problem to view the image as cylindrical view.
    i.e, the image moved at the end position ,the image seems to jump to the start.
    instead of this the image should view as cylindrical view. i.e, that the end of the image sticks to the beginning of the image.
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.MediaTracker;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    public class PanoramaImageDemo
         private BufferedImage biBackground = null;
         private JFrame f;
         PanoramaImageDemo()
              f = new JFrame("AniDemo 1.0");
              f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              loadBackground("C:/Documents and Settings/All Users/Documents/My Pictures/Sample Pictures/sunset.jpg");
              myPanel p = new myPanel(biBackground);
              f.add(p);
              f.pack();
              f.setVisible(true);
         private void loadBackground(String fn)
              File file = new File(fn);
              BufferedImage image = null;
              try
                   image = ImageIO.read(file);
              catch (IOException e1)
                   System.out.println("File Not Found");
              MediaTracker mt = new MediaTracker(f);
              mt.addImage(image, 0);
              try
                   mt.waitForID(0);
                   biBackground = new BufferedImage(image.getWidth(), image
                             .getHeight(), BufferedImage.TYPE_INT_RGB);
                   Graphics2D g2 = biBackground.createGraphics();
                   g2.drawImage(image, 0, 0, null);
                   g2.dispose();
              catch (InterruptedException e)
                   System.out.println(e.toString());
         public static void main(String[] args)
              new PanoramaImageDemo();
         class myPanel extends JPanel implements ActionListener
              private BufferedImage background;
              private BufferedImage bi = null;
              private int upperLeft = 0;
              int width;
              int height;
              myPanel(BufferedImage bg)
                   super();
                   background = bg;
                   width = background.getWidth() / 2;
                   height = background.getHeight();
                   bi = background.getSubimage(upperLeft, 0, width, height);
                   setPreferredSize(new Dimension(width, height));
                   Timer t = new Timer(5, this);
                   t.start();
              public void actionPerformed(ActionEvent e)
                   upperLeft += 1;
                   if (upperLeft >= width)
                        upperLeft = 38; // adjust to make rollover seemless
                   bi = background.getSubimage(upperLeft, 0, width, height);
                   repaint();
              public void paintComponent(Graphics g)
                   g.drawImage(bi, 0, 0, this);
    }plz help me regarding this concept

    I have learnt a technique when I am programming in flash.
    Assume you have a photo cat.jpg with 10 units in width and 10 units in height. You can have a view(viewport) 10 units in width and 10 units in height.
    The following shows the width of the photo:
    012345679
    To show an effect of panorama, you can draw 2 photo at any time. I assume the eyesight of a person move from left to right with 1 unit at a time.
    The original image is 0123456789.
    If the person move eyesight to right by one unit, the image become
    1234567890
    If the person move eyesight to right by one more unit, the image become
    2345678901
    You can program the by drawing 2 images at any time.
    0123456789(zero width for second image)
    123456789(0, 1 unit in width in second image)
    23456789(01, 2 unit in width in second image)
    To display part of image, try this link to a program to crop image
    http://www.java2s.com/Code/Java/2D-Graphics-GUI/Imagecrop.htm

  • How to get the text to appear on top of the image

    I am using the following piece of code to add a label to a JPanel -
    JLabel label = new JLabel();
            label.setIcon(new ImageIcon("object.gif"));
            label.setText("An object");
            label.setBounds(xCoordinate, yCoordinate, width, height);
            display.setLayout(null);
            display.add(label);The problem is that the image is being placed over the text so I cannot see the text, does anyone know how I can fix this?
    Thanks.

    Try setIconTextGap in JLabel. Or, maybe your bounds
    are too small.
    JLabel also has a constructor that takes both the
    icon and the text at the same time.I know my bounds are large enough because if I comment out the add image then I can see the text and there is enough room for it.
    I don't think setIconTextGap can help me because that will just move the position of the text in relation to the image but I would like it to be directly on top of the image.
    I tried the constructor but that is causing a java.lang.reflect.InvokationTargetException which is fairly strange because the method that im working on does not use reflection or change anything in the method which does.

  • Can't show the image in Firefox

    I have a problem to show the image in Firefox. They can show
    in Explorer. Does anyone help me with this? You can visit the site:
    www.norskbrannsikkerhet.no to see the problem.

    The problem is the source for the image, you have
    <img src="X:\CVS Norge\94 Prosjekter\945
    Trading\SovReflex\Bilder\Thumbs\litenalarmpakke_it400.jpg"
    alt="test"
    border="0" align="top" id=""
    onclick="MM_goToURL('parent','produkter/prodDetal.cfm?ProdID=21');return
    document.MM_returnValue" />
    So the source for the image is referring to a filepath, ie
    X:\ rather than a
    web path, so you`ll only see the image on your computer
    connected to the X
    drive. You need to change it to a web relative path, and then
    it will work.
    Gareth
    http://www.phploginsuite.co.uk/
    PHP Login Suite V2 - 34 Server Behaviors to build a complete
    Login system.

  • HiDPI (2x) don't export correct size. Even when I imported the image in larger size (original)

    It is an image of 5118X1441, and 144 resolution. 
    From the assets panel I imported like a larger size image
    When I see her on preview in browser, size automatically switches to a smaller one again. The same happens when I export or upload to server.
    Another problem is that the images are not vicibles on iPhone 5s (have retina display) Not even the 72 pixels version.
    I would appreciate any help.

    Hi,
    Check this article, under "Exporting HiDPI images"
    Adobe Muse Help | Creating High Resolution websites
    See if that helps. Do let me know if you have any question.

Maybe you are looking for