Embedding images into servlets

I have a problem with showing two png files (or jpg files) in the same servlet. I probably thought that I cannot.
So I thought I will do the following: Load a html file as output to the user and include references to two servlets, each displaying one png file. Do I have to use .shtml file to do that? And how do I send the HTTPRequestInfo I get from my original servlet to these 2 servlets?
thanks
Mahesh :)

How do I use the img tag?? I was reading my .png file and creating a ByteArray of data (pixel info) and output that through ServletOutputstream. I am using response.setContentType("image/png"). If I did this with 2 image files, only the first one wud show up.
please advise.
thanks
mahesh

Similar Messages

  • How to insert embedded image into TextArea htmlText (and add IOErrorEvent.IO_ERROR listener).

    I unsuccessfully tried to find way to insert embedded image into TextArea via <img> tag. Can you point me out how to do this?
    Also, please, tell me how to handle IOErrorEvent from TextArea because adding IOErrorEvent.IO_ERROR listener to TextArea doesn't cause any effect when image url of img tag has not been found.
    Thanks

    i 've successfully inserted the image into the database... here is my code
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package PMS;
    import java.io.File;
    import java.io.FileInputStream;
    import java.sql.Blob;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    public class Browse_java
    static Connection con=null;
    public static void main(String args[])
    try{
    System.out.println("(browse.java) just entered in to the class");
    con = new PMS.DbConnection().getConnection();
    System.out.println("(browse.java) connection string is"+con);
    PreparedStatement ps = con.prepareStatement("INSERT INTO img_exp VALUES(?,?)");
    System.out.println("(browse.java) prepare statement object is"+ps);
    File file =new File("C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    FileInputStream fs = new FileInputStream(file);
    byte blob[]=new byte[(byte)file.length()];
    fs.read(blob);
    ps.setString(1,"C:/Documents and Settings/Administrator/Desktop/Leader.jpg");
    ps.setBytes(2, blob);
    System.out.println("(browse.java)length of picture is"+fs.available());
    int i = ps.executeUpdate();
    System.out.println("image inserted successfully"+i);
    catch(Exception e)
    e.printStackTrace();
    finally
    try {
    con.close();
    } catch (SQLException ex) {
    ex.printStackTrace();
    }

  • Embedding images into connector.

    I've created a custom component that will pop-up to display errors when my connector has problems.  After working around some styling limitations within the SDK, I've managed to get everything laid out and working great.  Now I'm at the last hurtle.
    I've embedded images that will be displayed.  For example, an image to represent an error.  Now during debugging in Flex Builder, obviously, the image displays.  I compile and package up my component and head off to Xcelsius.  Now this is when it gets weird.
    I'm using Xcelsius Enterprise 5.3.0.0, Build No. 12,3,0,670
    I add in my connector to a dashboard, and then press "Preview" (no configuration needed, as i just display a test message for now).
    The dashboard comes up, the test message is displayed, but no image is present.
    Now i click on "Preview" again to get back into the designer.  Then i press preview again without making any other clicks or changes to the dashboard.  Now i'm presented with a dashboard, the message pops up, and my image is clearly visible.
    The image is consistently not displayed on the very first preview of the dashboard.  And it's consistently displayed in the second and any future previews of the dashboard.

    Hi
    That is a bug actually. you can follow
    Problem with button Icons
    Hope helps
    Rush-me

  • Embeding image into XML document

    Hi,
    I am in need to embed image into XML file so that when somebody else uses the XML file, the image is still there. Is there any way to do this? Is it possible? Please give me some suggestions if you know about.
    Thanks a lot.

    well, the blowup in size from 3MB to 5MB is expected when you do the text encoding, cause you are taking binary data and converting it to a small range of characters. there are alternate algorithms which result in less of a blowup than base64 (like ascii85), see:
    http://en.wikipedia.org/wiki/Category:Binary-to-text_encoding_formats
    most image files use some sort of compression algorithm, which is why your file is much smaller than the image byte[]. you could just stick the file byte[] in the xml, but you might need to add additional attributes to indicate the image encoding (e.g. "gif" or "jpg").
    but, basically, you aren't doing anything "wrong".
    Edited by: jtahlborn on Feb 26, 2008 2:31 PM

  • Embedding images into emails?

    PC users I know can copy and paste JPEGs into emails so that they are not attachments and are open when recipients open the mail. I have not been able to figure out how to do that on my G4. When I use that method, the graphic appears as an attachment. Anyone know a way? Surely there is one...

    Hi
    That is a bug actually. you can follow
    Problem with button Icons
    Hope helps
    Rush-me

  • Embedding an image into Mail

    How exactly do you embed images (.jpeg) into a mail message so that it does not come up as an attachment?
    Gmail, outlook, yahoo mail, etc. all read attachments as an attachment that needs to be opened and only through Apple Mail can users see an attachment already opened (giving the appearance of an embedded image, but it's not).
    Any help on embedding images into Apple Mail (besides through using the signature)?

    I tried creating a Stationary but I am fairly new to Mail and am unfamiliar with creating it successfully. I create it, then it creates the Custom folder in which my stationary will not show up in the mail message. It will show up in the folder, I just am unable to get it to show up in the message. Is there a format to creating stationaries? Or perhaps a different way to embed images?

  • How To: Using Embedded Images for Drawing Fills

    I had some challenges making this seemingly simple feature work, so as I found no examples, I made an example on how to do this.  The key I found was using the “BitmapAsset” class which is compatible with posting our embedded image into BitmapData objects. That put things together.
    See the full narrative at:  http://digitalshowcase.biz/wordpress/?p=234
    Download the Flex Project here:  http://digitalshowcase.biz/flex/FillsWithEmbeddedImages.zip
    - Alan Gruskoff, Digital Showcase LLC

    >>says that this export technique does not work, it produces a low res screen version of the file.
    Are you certain the original files were any better?
    My preferred method of doing this works well, but it takes a few extra steps. I'd make a high-res PDF out of the PM file, then pick apart the PDF to extract the graphics. Are the graphics raster or vector? If they're raster, you can use Acrobat's Touch-up Object tool to open them in Photoshop. If they're vector, you can open the PDF in Illustrator and save out the graphics from there.
    HTH

  • AI CS6 vectors turn into embedded image when using clipping mask

    AI CS6 vectors turn into embedded image when using clipping mask, how to solve it?

    With the Clipping Mask selected go here

  • [svn] 663: Fix SDK-14201: Performance: embedded images are written into the swf one byte at a time.

    Revision: 663
    Author: [email protected]
    Date: 2008-02-26 13:56:08 -0800 (Tue, 26 Feb 2008)
    Log Message:
    Fix SDK-14201: Performance: embedded images are written into the swf one byte at a time.
    This changes the way swfs are written out when they contain embedded lossless images,
    such as PNGs and GIFs. The old code had a loop to write a byte at a time; the new code
    does a single biblt. The result is a modest compilation speedup, on the order of
    several hundred milliseconds when compiling Flexstore.
    (This already went into the trunk as revision 658.)
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-14201
    Modified Paths:
    flex/sdk/branches/3.0.x/modules/swfutils/src/java/flash/swf/TagEncoder.java

    Hiya, Mike,
    It's pretty tough to work through pasted-in code. If you can, please upload a page to a server, so we can see your pages in context. We'll be able to download it and look at it.
    That said, you can do this: Find the beginning of an editable region in Code View. It will look like this:
    <!-- InstanceBeginEditable name="nameofregionhere" -->
    Click anywhere in that tag, between the opening bracket and the closing bracket.
    Then, on the vertical toolbar on the left side of the Code window, click on the "Collapse Full Tag" button. It is the one with two arrows pointing at each other. This will collapse that entire editable region. Then click the button with the two arrows pointing away from each other. That will re-open the editable region, but will highlight it.
    If you have nested regions, you will find the other inside one of the editable regions. If you copy the <!-- InstanceBeginEditable and do a search on it in that document, you will find the nested region.
    Beth

  • [svn] 658: Fix SDK-14201: Performance: embedded images are written into the swf one byte at a time.

    Revision: 658
    Author: [email protected]
    Date: 2008-02-26 11:28:16 -0800 (Tue, 26 Feb 2008)
    Log Message:
    Fix SDK-14201: Performance: embedded images are written into the swf one byte at a time.
    This changes the way swfs are written out when they contain embedded lossless images,
    such as PNGs and GIFs. The old code had a loop to write a byte at a time; the new code
    does a single biblt. The result is a modest compilation speedup, on the order of
    several hundred milliseconds when compiling Flexstore.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-14201
    Modified Paths:
    flex/sdk/trunk/modules/swfutils/src/java/flash/swf/TagEncoder.java

    Thanks John,
    I've downloaded the exif tool + the gui - I can see how it's meant to work and have successfully processed a single file (even when I got the name wrong it still copied exif time data!)
    I'll investigate further on how to do a batch and use command line
    Really appreciate your prompt response to my problem. 
    I will let you all know how I get on - will take quite a few weeks but I am confident I can get there!
    Thanks Mike
    A week later I've now got back into this.  I used the exif gui tool - which was very simple to use once I sat down with peace and quiet for 10 mins!  I successfully copied and updated the correct exif data including capture time from the original backup files.  My metadata keywords remained untouched when I then updated the metadata setting from disk in lightroom.
    exif is a great tool, and I found it easier to use than AM pro - I couldn't  see the photo attributes in the trial download so made it hard to sort by date.
    Anyway my problem was overcome thank you

  • LabVIEW RunTime into xp embedded image

    Hello,
    I need to integrate the LabVIEW 2009 Runtime into an XP Embedded image. That means I have to create a LabVIEW RunTime Component (SLD File) for the XPe Target Designer. Installing LabVIEW RunTime on the target does not work for me.
    Is there a sld file available somewhere or has anybody some experiances to share?
    Thanks and best regards
    D. Ackermann

    Joshua-
    You can use two freebee utilities to track registry entries-
    InCntl5 monitors additions, changes, and deletions to registry entries and files when you install the SW on your development system, and you can use the output listing in conjunction with the "import registry branch" and "Files in Folder" tools in the Component Designer.
    Depends monitors file usage while your application is running, so you know to add specific windows components in your base configuration in Target Designer, such as certain DLLs that Labview calls that wouldn't be included in a stripped version of eXP without adding additional bulky windows XP components.
    If you have any questions, you can email me- I'd be glad to help
    grekATneoceraDOTcomNOSPAM

  • How to import MS Word docs into a Wiki (with embedded images

    What is the best way to import a lot of large MS Word docs (50+ pages) with images into a Wiki-Folder?
    I know that you can copy&paste the text and still preserve the formatting, but i'd still have to import the images manually.
    Is there something planned like Word2MediaWikiPlus?

    Originally Posted by rkattenberg
    Use webdav of set up a email feader.
    I don't understand. If we use Webdav, we can access and share Office-documents, but we want to create a Wiki-structure with links etc.

  • Unable to load TIF images into Photoshop.

    CS4 (11.0.2) and Windows 7 Home Edition.
    Have developed a problem trying to load some TIF images into Photoshop. I have a large number of images archived over a decade or more. At this point it may some of the older files that exhibit the problem. Now all these files were edited and stored using the Photoshop versions during the complete time period. The files are always saved with no compression. Have tried to load from Photoshop and clicking on the file in a file list. Photoshop just hangs and I get the message Program not responding. I can take these same files and load them into the ROXIO photo editor with no problem. Stranger yet is if I simply load the file into the ROXIO editor then "save as" back into the same folder (overwrite) the file can then be brought into Photoshop with no problem! Any ideas?

    Noel,
    Will try to keep short.
    I reinstalled Photoshop CS4 from the cd CS set. Did not uninstall first. Restarted PC and Photoshop. Still failed the same way with a 3001 image.
    Did the following, changing one item in the Edit->Preference->GPU Setting. After each change, closed Photoshop, reopened, brought in 3001 image, restored original setting. 3001 failed each time.
    * Unchecked Enable OpenGL Drawing
    * Advanced setup: Unchecked Advanced Drawing.
    * Advanced setup: Unchecked Color Matching
    Next went to the Edit->Color Profile.
    Scanned thru options and saw in the Convert Options: Engine. It was set to Adobe (ACE). ACE was the module name in the error detail!
    Only other option for this is Microsoft ICM. Changed to that, close/open Photoshop and 3001 came in no problem. So did the Nikon 3000, srgb IEC 61922 2.1 and Untagged. However, when briging in an Adobe RGB(1998) image Photoshop notes Profile Mismatch. It allows me to decide what to do (use embedded profile instead of workspace; convert color to work space color; discard embedded profile. and I choose use the convert color and it loads ok. At least it loads the image! Will use this approach for now. I need to get educated on color profiles!!
    Joe

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

  • Why can't I print embedded images in a Thunderbird E-mail? I just get blank boxes for the images.

    I am a copyeditor who receives feedback from my clients re: manuscripts I have edited. They will often sent e-mails that include small screen captures from parts of their style guide or screen captures of the proof that is in question (small sections, like a paragraph or an equation, or a header that needs to be coded/styled differently for HTML). Now, I can see these fine in the e-mail, but when I go to print them out for my reference binder, the embedded images don't print.
    Mozilla, I need these to print; they are quite important to my job.
    To keep my e-mail from becoming too bloated, I save these important style issue e-mails into a folder on my desktop I call "Print out for binder", queuing them for the day I can print a bunch of them out and arrange them according to subject matter.
    Problem is, they are useless if they don't include these illustrative screen captures; blank boxes are worthless to the context.
    It is not my printer that is the problem. if I receive a Word doc with these screen captures, they print fine. But if I try to print from T-Bird, no go. Help. (I can't save these e-mails as Word docs either, which might solve the problem; the only options in T-Bird are "Save as file" or "Save as template".)
    Thunderbird is a powerful e-mail program, and one I have been using for over a decade. Why can't it perform this function? Please help. Or point me to an add-on. I haven't been able to find one that addresses this seemingly straightforward, common, and simple problem.

    When you select File(or AppMenu/Print)/Print Preview, do the images appear? Do the images print if you check 'Print background (colors & images)' under File/Page Setup? I don't have any problems printing a message with an embedded image, at least to an xps file.
    I devised a workaround that might help, failing a real solution: install [https://addons.mozilla.org/en-US/thunderbird/addon/unmht/ unMHT] in both TB and Firefox, and then File/Save As MHT in TB. Open the mht file in Firefox, and Print.

Maybe you are looking for