Java image in html

i hav created a jpg file using java...
i need to use that file to display it in a table cell in html...
how can i do that...

sghai_7 wrote:
i hav created a jpg file using java...
i need to use that file to display it in a table cell in html...
how can i do that...Use the HTML <img> element. There's a HTML tutorial at w3schools.com. If the image is not located in public webcontent, then you need to create a Servlet class as well. It's fairly simple: read the image as InputStream from disk and write it to OutputStream of response.
For future servlet related questions better use the Java Servlets forum. This is the general Java Programming forum.

Similar Messages

  • MIME Multipart/related to embed images in html files - Servlet

    Hello,
    My goal is to embed images in html/xhtml files to decrease latency when using slow networks. Think about mobile phones, if I have 10 images in one page, I will have 11 requests/responses to get the whole page.
    The solution would be to embed all images using Content-type multipart/related, so I have one request to the whole pack.
    How to do that in java? I mean, I need to set the content-type and build all parts encoding the images to base64.
    I tried JavaMail API, there I can build messages like this and instead of send an e-mail, I can write:
    myMimeMultipart.writeTo(response.getOutputStream());
    The problem is: I am getting everything as text in my browser, including the MIME headers of each part. Another think is that the first header (the main one) doesn't appear too.
    Any thoughts/other ideas?
    Thanks in advance,
    Andr� Carlucci

    If memory serves me right, I believe in the Servlet spec you have access to the Response object. You "should" be able to set any headers you need there. In addition, you can get the output streams just as you described.
    I did a similar thing, although slightly modified, to output dynamically-generated XLS (Excel Spreadsheet) files using a reporting engine called JasperReports. It wasn't a multipart response, however, so you may need to figure out how to handle that part of it, but in my case I set the mime-type header, then grabbed the output and started writing my XLS file too it. Once done, you close the streams and return the response. Worked perfect.

  • Re: [iPlanet-JATO] Tomcat 3.2 serving images and html?

    First of all David you are faster responding to email than I am. Thanks.
    We tried your scheme with no luck. You are using "ROOT" as your war file
    name ROOT, correct? Are you sure the jsp would reference
    "/images/MyProject/nppnback.gif"? Why is "MyProject" in there? Where is
    the directory "images" defined to Tomcat? Is it a default?
    Here's another try at explaining:
    In my JSP I have;
    <IMG SRC="/images/ef.gif" ALT=People Banner">
    My application is in webapps/EformsAppWar
    (jsps in EformsAppWar/EformsApp/eforms/*.jsp)
    (classes in EformsAppWar/WEB-INF/classes)
    so images are in webapps/EformsAppWar/images
    and there is, indeed a ef.gif there.
    However with no server.xml changes (everything default), Tomcat 3.2
    gives a 404 in his log and states in the 404 message that context is
    null (CTX < >) and ca't find /images/ef.gif + NULL.
    By the way I just noticed that in Tomcat 3.1 I have the images directory
    directly under webapps.
    ----- Original Message -----
    From: "David J.L. Martin" <<a href="/group/SunONE-JATO/post?protectID=114166018056146134184102046176231239071179066034">dave@t...</a>>
    Date: Wednesday, May 23, 2001 3:35 pm
    Subject: Re: [iPlanet-JATO] Tomcat 3.2 serving images and html?
    This works:
    If the doc root is webapps\ROOT --
    Using defaults...jsp's would be put in
    webapps\ROOT\MyProjectApp\MyProject\*.jsp
    and images would be put in webapps\ROOT\images\*.gif
    Then in your jsp...use the following reference:
    "/images/MyProject/nppnback.gif">
    That will work just using defaults and not playing with any of the
    config files...
    ie. webapps\ROOT\WEB-INF gets updated as well (with required
    classes).
    djm
    TechPie
    916 924-1832 (office)
    916 730-4743 (mobile)
    916 313-3531 (fax)
    <a href="/group/SunONE-JATO/post?protectID=114232044112042209130232046248130100239179057215113109152006048067">dmushrush@e...</a> wrote:
    Many of you are running Tomcat 3.2. Can anyone tell me how to get
    images to be served by Tomcat. In 3.1 if I referenced /images/image.gif> in my JSP, I could just place the images
    directory in the application
    (context) directory.
    The default docBase is webapp> that webapp> relative addressed as /images/image.gif but such is not the case.
    I have put the images directory almost everyplace possible with no luck.
    I have explicitly defined docBase in tomcat/conf/server.xml and still no
    luck.
    I currently have the following in conf/server.xml
    <Context path="/EformsAppWar"
    docBase="c:/tomcat/webapps/EformsAppWar"
    crossContext="true"
    debug="0"
    reloadable="true" >
    </Context>
    I place images in that directory structure but still take 404's and in
    the log it refers to context as /images ????
    I'm probably doing something (or not doing something) foolish. Anybody> have a remedy.
    <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215146166214017110250006230056039126077176105140127082088124241215002153">[email protected]</a>
    <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215146166214017110250006230056039126077176105140127082088124241215002153">[email protected]</a>

    First of all David you are faster responding to email than I am. Thanks.
    We tried your scheme with no luck. You are using "ROOT" as your war file
    name ROOT, correct? Are you sure the jsp would reference
    "/images/MyProject/nppnback.gif"? Why is "MyProject" in there? Where is
    the directory "images" defined to Tomcat? Is it a default?
    Here's another try at explaining:
    In my JSP I have;
    <IMG SRC="/images/ef.gif" ALT=People Banner">
    My application is in webapps/EformsAppWar
    (jsps in EformsAppWar/EformsApp/eforms/*.jsp)
    (classes in EformsAppWar/WEB-INF/classes)
    so images are in webapps/EformsAppWar/images
    and there is, indeed a ef.gif there.
    However with no server.xml changes (everything default), Tomcat 3.2
    gives a 404 in his log and states in the 404 message that context is
    null (CTX < >) and ca't find /images/ef.gif + NULL.
    By the way I just noticed that in Tomcat 3.1 I have the images directory
    directly under webapps.
    ----- Original Message -----
    From: "David J.L. Martin" <<a href="/group/SunONE-JATO/post?protectID=114166018056146134184102046176231239071179066034">dave@t...</a>>
    Date: Wednesday, May 23, 2001 3:35 pm
    Subject: Re: [iPlanet-JATO] Tomcat 3.2 serving images and html?
    This works:
    If the doc root is webapps\ROOT --
    Using defaults...jsp's would be put in
    webapps\ROOT\MyProjectApp\MyProject\*.jsp
    and images would be put in webapps\ROOT\images\*.gif
    Then in your jsp...use the following reference:
    "/images/MyProject/nppnback.gif">
    That will work just using defaults and not playing with any of the
    config files...
    ie. webapps\ROOT\WEB-INF gets updated as well (with required
    classes).
    djm
    TechPie
    916 924-1832 (office)
    916 730-4743 (mobile)
    916 313-3531 (fax)
    <a href="/group/SunONE-JATO/post?protectID=114232044112042209130232046248130100239179057215113109152006048067">dmushrush@e...</a> wrote:
    Many of you are running Tomcat 3.2. Can anyone tell me how to get
    images to be served by Tomcat. In 3.1 if I referenced /images/image.gif> in my JSP, I could just place the images
    directory in the application
    (context) directory.
    The default docBase is webapp> that webapp> relative addressed as /images/image.gif but such is not the case.
    I have put the images directory almost everyplace possible with no luck.
    I have explicitly defined docBase in tomcat/conf/server.xml and still no
    luck.
    I currently have the following in conf/server.xml
    <Context path="/EformsAppWar"
    docBase="c:/tomcat/webapps/EformsAppWar"
    crossContext="true"
    debug="0"
    reloadable="true" >
    </Context>
    I place images in that directory structure but still take 404's and in
    the log it refers to context as /images ????
    I'm probably doing something (or not doing something) foolish. Anybody> have a remedy.
    <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215146166214017110250006230056039126077176105140127082088124241215002153">[email protected]</a>
    <a href="/group/SunONE-JATO/post?protectID=210083235237078198050118178206047166215146166214017110250006230056039126077176105140127082088124241215002153">[email protected]</a>

  • In Mail 3.6 remote images in HTML messages display as blue squares with ? even though checked in viewing references.

    In Mail 3.6 remote images in HTML messages display as blue squares with ? even though checked in viewing references.

    Nurit,
    The point is that that button should not be there, if the preference setting is as you say. This indicates the preference setting is stuck, and that is what I was trying to help you resolve.
    The full purge is done as follows:
    Quit Mail, and in the Finder open Home/Library and locate the Mail folder. Control-click over the Mail folder, and choose Duplicate -- then drag the resulting copy to the Desktop for temporary backup. Next, open Home/Library/Preferences and find the com.apple.mail.plist file and drag it to the desktop.
    Relaunch Mail, which will open as though new, and when prompted to import anything DECLINE. Instead, re-enter your account info, and Mail will re-discover the account folders for your accounts, and all should be well, after setting preferences as you desire.
    Ask any needed questions, and keep us posted.
    Ernie

  • Display image in html mail

    I was recently sent an email that used an HTML stationery wih several photos embedded in it.  The email opens normally, but all of the images are icons, displaying file name and size.  If I click the icon, the image opens correcly in a separate window. 
    I am running OS X 10.7.3 and Mail 5.2 (1257) and have checked "display remote images in html email" in preferences.  A friend with identical software versions receives the same email and the photos are visible in the original email. Suggestions?

    No-one replied, but I found a solution on another board. Run Terminal (do a Spotlight search if you don't know where to find this), and type: (or copy and past the next line)
    defaults write com.apple.mail DisableInlineAttachmentViewing -bool false
    This will force Mail not to disable inline attachment viewing. Obviously, to reverse this, simple replace 'false' at the end with 'true'.
    Thanks to Louise101 from July 2011 for posting this.

  • Problem while calling java function from html

    when i tried to call a java function from html i'm getting an error
    object don't support this property.
    what could be the reason.
    This is my html.
    I got this from this forum only.
    My applet is accessing the system property "user.home".
    I ran it in IE
    <DIV id="dvObjectHolder">Applet comes here</DIV>
    <br><br>
    <script>
    if(window.navigator.appName.toLowerCase().indexOf("netscape")!=-1){ // set object for Netscape:
         document.getElementById('dvObjectHolder').innerHTML = " <object ID='appletTest1' classid=\"java:test.class\"" +
    "height=\"0\" width=\"0\" onError=\"changeObject();\"" +
              ">" +
    "<param name=\"mayscript\" value=\"Y\">" +
    "<param name=\"archive\" value=\"sTest.jar\">" +
    "</object>";
    }else if(window.navigator.appName.toLowerCase().indexOf('internet explorer')!=-1){ //set object for IE
         document.getElementById('dvObjectHolder').innerHTML = "<object ID='appletTest1' classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"" +
              " height=\"0\" width=\"0\" >" +
              " <param name=\"code\" value=\"test.class\" />" +
         "<param name=\"archive\" value=\"sTest.jar\">" +
              " </object>"
    </script>
    <LABEL id="lblOutputText">This text will be replaced by the applet</LABEL>
    <BR>
    <input value="Javascript to java" type=button onClick="document.appletTest1.fromJavaScript()">

    I tried this example using the repy given to an earlier post.
    But its not working with me.
    What i did in addition was adding plugin.jar to classpath to import netscape.javascript.*;
    Let me add some more details
    1) I'll add the stack trace
    2) my java progrma
    3) batch file to sign the applet.
    1) This is the stack trace i don't know whether u will undertand this
    load: class test.class not found.
    java.lang.ClassNotFoundException: test.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\FastranJava\AppletObject\bin\test\class.class (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Exception in thread "Thread-5" java.lang.NullPointerException
         at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
         at sun.plugin.AppletViewer.showAppletException(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    2) Java Program
    import netscape.javascript.*;
    import java.applet.*;
    public class test extends Applet
         private JSObject win;
         private JSObject outputLabel;
         private boolean buttonFromJavaClicked=false;
         checkJavaScriptEvent evt=new checkJavaScriptEvent();
         public void init()
              try
                   evt.start();
                   win=JSObject.getWindow(this);
                   outputLabel=(JSObject)win.eval("document.getElementById('lblOutputText')");
                   outputLabel.setMember("innerHTML", "<center><h1>From Init<br>Your Home directory" + System.getProperty("user.home") + "</h1></center>");
              catch(Exception e)
                   e.printStackTrace();
         public void fromJavaScript()
              buttonFromJavaClicked=true;          
         public void fromJavaScript2()
              System.out.println("Started Form JavaScript2");
              try
                   String strLbl="<center><h1>From JavaScript<br>Your Homedir:" + System.getProperty("user.home") + "</h1></center>";
                   outputLabel.setMember("innerHTML", strLbl);
              catch(Exception e)
                   e.printStackTrace();
         class checkJavaScriptEvent extends Thread
              public void run()
                   while(true)
                        if(test.this.buttonFromJavaClicked)
                             System.out.println("OK buttonfromjava is true");
                             test.this.buttonFromJavaClicked=false;
                             fromJavaScript2();
                        try
                             Thread.sleep(3000);
                        catch(Exception e)
                             e.printStackTrace();
    3) Batch file
    del *.cer
    del *.com
    del *.jar
    del *.class
    javac -classpath ".;C:\Program Files\Java\jre1.5.0_06\lib\plugin.jar" test.java
    keytool -genkey -keystore harm.com -keyalg rsa -dname "CN=Harm Meijer, OU=Technology, O=org, L=Amsterdam, ST=, C=NL" -alias harm -validity 3600 -keypass password -storepass password
    jar cf0 test.jar *.class
    jarsigner -keystore harm.com -storepass password -keypass password -signedjar sTest.jar test.jar harm
    del *.class

  • Problem in Displaying image in HTML format for BI Publisher (OTM)

    Hello,
    We are using OTM 6.2 and we are developing the IB reports to the customer.
    I am getting dificulty while displaying the image in HTML format. I used image in JPEG format. When i am running the report, It displayed only in PDF format, but not in HTML and Excel format.
    Please do the needful help in this regards.
    Thanks & Regards,
    Siva Donthi

    Hi Kavipriya,
    i have gone thru all your threads on a similar sort of issue which i am facing now, However i m bit struck as i m newbie.
    Issue:i am insering a static picture from the c drive into the header section of the rtf template and when previewing the rtf template on the BI publisher the jpg image disappears. i have tried adding the url into the format picture -->alt tab.Still no signs of improvement.
    However if just placing the jpg image on header section without using the wrap text it gets displayed.But if i use wrap text on the image ,it disappears.
    could you guide me please in fixing this issue .
    Appreciate your timely response and your co-operation
    Thanks
    Joe

  • How to remove cached images in html whe going from one page to another page

    can anybody help how to remove cached images in html pages.i tried with response.setHeader("no-cache") but it is not working

    thanks,
    can u tell me how to make the browser not to cache images.since iam moving from one page which has images, into another page which having few more images both gets overlaped so how to remove images of previous page.
    thanks in advance

  • Load remote images in html mail setting does not get saved. I have to turn it off every time I log in. Is this a bug?

    Load remote images in html mail setting does not get saved. I have to turn it off every time I log in. Is this a bug?

    Plug your phone into the wall charger for at least 30 minutes...make sure you have a sim card in the phone...then:
    Leave the USB cable connected to your computer, but NOT your phone, iTunes running, press & hold the home button while connecting the USB cable to your dock connector, continue holding the home button until you see “Connect to iTunes” on the screen. You may now release the home button. iTunes should now display that it has detected your phone in recovery mode, if not quit and reopen iTunes. If you still don’t see the recovery message repeat these steps again. iTunes will give you the option to restore from a backup or set up as new.
    Make sure you have no anti-virus software running or any firewalls...turn all of that stuff off.

  • How to include image or html dynamically in a JSP?

    I need to show the uploaded content in a jsp. It could be either a image or html file. How can i include these images or html files dynamically without affecting screen design.

    What the heck is 'screen design'? You mean the page layout?
    You could show in a popup div; JQuery will be your best bet for a prebuilt function to do that. But you'd need to put the uploaded file in a place where the browser can fetch it through an URL, or you need to create a servlet that can load and return the data to the browser.

  • By saving for web text-layer becomes a image in HTML what is wrong?

    By saving for web text-layer becomes a image in HTML what is wrong? In this way I can not use CSS in the editor.

    Right click on the layer, Duplicate Layer, set destination to the other image file in the dropdown.

  • Inserting JAVA program in HTML

    I want insert a program made with JAVA in a HTML file. How can I do it? I think is not possible!!
    THANKS, JUAN

    I have a hard time believing that this can't be an applet. You might not want it to be an applet, but you should be able to do anything in an applet that you can do in an application. The only way I know to run it on a web page is to make an applet.
    If this has to be an application, I think you're only option is to allow the user to download and run it.
    Here is a link for making jar files more or less runnable.
    http://forum.java.sun.com/thread.jsp?forum=22&thread=196383
    You might also look at Web Start
    http://java.sun.com/products/javawebstart/

  • How to embed images in HTML

    i was wondering if i could embed images into html and end up with a single file

    olafgarten212 wrote:
    i was wondering if i could embed images into html and end up with a single file
    No you can't.  An image file is an image file while HTML file is simply a text file that can be read and edited with any text editor.  Image files can't be edited in the normal way without the use of special programs like Photoshop, fireworks, and other free ones that can be downloaded.
    However, as your question is vague as pointed out by Nancy O, I would hazard to guess that you want to save a webpage that can be viewed off-line.  If this is the case then I suggest use Internet Explorer to save the page as .mht file.  This will allow you to have a complete page including images and style sheets all in one file.
    The file is saved as:  File >> save as >> "myfile.mht"
    The saved file is a single web archive, single file that can also be edited in Microsoft Word.
    Good luck.

  • How to use add image in HTML tag

    Hello frndz
                     i  m working on text chat application in adobe  air.using <mx:html/> tag for dispalying text and  images(smiley).but the font size fo flex is diffrent and html diffrent.i  mean i m using 10 font size but it looks too large on  <mx:html/>  component.is there any way to cast them in same size.
    The second and major problem is that it can not add images to html  tag.when i m giving images like:-private var txt:String="<img  src='src\smily\tongue.gif'/>" .
    it shows nothing but when i give images through http path it shows  images on html componenet.
    can any body explain me the problem.
    Thanks And regards
      Vineet Osho

    thanks Alot René Bühling for  your quick reply.but the link u mentioned ith reply is not working for  me.
    ok can u tell me how can i manage my flex font  size 10 to  <mx:html tag 's font size 10.
    i think there is large difference  between flex font and html font.so please guide me for that.
    Thanks  Alot
    Vineet osho

  • How to call java program by HTML page

    Hi guys,
    I'm new java programer and want to build an HTML page to access to ORACLE database on NT server by JDBC, Can anyone give me a sample?
    I already know how to access database by JDBC, but I don't know how to call java program by HTML page.
    If you have small sample,pls send to me. [email protected], thanks in advance
    Jian

    This code goes with the tutorial from this web page
    http://java.sun.com/docs/books/tutorial/jdbc/basics/applet.html
    good luck.
    * This is a demonstration JDBC applet.
    * It displays some simple standard output from the Coffee database.
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.util.Vector;
    import java.sql.*;
    public class OutputApplet extends Applet implements Runnable {
    private Thread worker;
    private Vector queryResults;
    private String message = "Initializing";
    public synchronized void start() {
         // Every time "start" is called we create a worker thread to
         // re-evaluate the database query.
         if (worker == null) {     
         message = "Connecting to database";
    worker = new Thread(this);
         worker.start();
    * The "run" method is called from the worker thread. Notice that
    * because this method is doing potentially slow databases accesses
    * we avoid making it a synchronized method.
    public void run() {
         String url = "jdbc:mySubprotocol:myDataSource";
         String query = "select COF_NAME, PRICE from COFFEES";
         try {
         Class.forName("myDriver.ClassName");
         } catch(Exception ex) {
         setError("Can't find Database driver class: " + ex);
         return;
         try {
         Vector results = new Vector();
         Connection con = DriverManager.getConnection(url,
                                  "myLogin", "myPassword");
         Statement stmt = con.createStatement();
         ResultSet rs = stmt.executeQuery(query);
         while (rs.next()) {
              String s = rs.getString("COF_NAME");
              float f = rs.getFloat("PRICE");
              String text = s + " " + f;
              results.addElement(text);
         stmt.close();
         con.close();
         setResults(results);
         } catch(SQLException ex) {
         setError("SQLException: " + ex);
    * The "paint" method is called by AWT when it wants us to
    * display our current state on the screen.
    public synchronized void paint(Graphics g) {
         // If there are no results available, display the current message.
         if (queryResults == null) {
         g.drawString(message, 5, 50);
         return;
         // Display the results.
         g.drawString("Prices of coffee per pound: ", 5, 10);
         int y = 30;
         java.util.Enumeration enum = queryResults.elements();
         while (enum.hasMoreElements()) {
         String text = (String)enum.nextElement();
         g.drawString(text, 5, y);
         y = y + 15;
    * This private method is used to record an error message for
    * later display.
    private synchronized void setError(String mess) {
         queryResults = null;     
         message = mess;     
         worker = null;
         // And ask AWT to repaint this applet.
         repaint();
    * This private method is used to record the results of a query, for
    * later display.
    private synchronized void setResults(Vector results) {
         queryResults = results;
         worker = null;
         // And ask AWT to repaint this applet.
         repaint();

Maybe you are looking for

  • 2014 mac mini slow

    I bought a 2014 mac Mini last week. just the basic one, my plan was to use it for iTunes and organize and edit photos. however its really frustrating. I am finding it unresponsive and slow. since I have had it it has crashed twice too.  Am I expectin

  • Photo resolution on iweb

    Does anyone know how to improve the photo resolution on iweb? Can i upload pics from iphoto to iweb with original file size?

  • Curve 9300 connecting to boot rom problem

    Hi everyone, I have a curve 9300 and I tried to install an update to the OS. The problem is when i get to the part that says "connecting to the boot rom" the phone starts rebooting and goes like this 3 or 4 times, resulting on a failed update. I alre

  • CS 6 Photoshop Doesn't Work

    I have to re-boot the computer every two or three images, grrr, or I have nothing but trouble. When in Camera RAW the image won't appear until it's opened in PS. I'm about ready to ask for my money back - I hate this version. All previous versions ne

  • Many credit cards

    My account have problem  for assistance  contact to apple  iTunes support Why