Setting html content with setContent() does never show images

I've an application set sets dynamically generated html-content in a webview node by using the webengine.setContent() method. This generated html content uses image-tags.
Here's the problem: the image is not displayed. I tried all variations (absolute url like "http://localhost/c:/test.png" or "file://c:/test.png", relative urls like "test.png" with png in jar-file).
Anyone out there who has a workaround for me? I appreciate any comment.

one non-working apple <img src="apple.png"> You loaded the page content with loadcontent, then inside the page content provided a relative url. This is likely an error.
The question is, what is this url relative to?
The answer is either likely undefined as no protocol was used to load the page content and so it can't be determined how to load the relative url resource.
and two non-working peaches <img src="http://localhost/c:/peaches.png">
You attempted to load content using the http protocol server on the localhost, but you have no such server on the host, so this cannot work.
and a working remote image url <img src="http://docs.oracle.com/javafx/javafx/images/javafx-documentation.png">
This works because you fully specified how to load the content by providing the protocol and valid resource reference.
OK, so the question remains how do you images from the local drive?
There are three options for this in the following code.
package org.jewelsea.examples.webviewlocal;
import javafx.application.Application;
import javafx.beans.value.*;
import javafx.scene.Scene;
import javafx.scene.layout.FlowPane;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
/** Example of a webview loading resources from the file system. */
public class WebViewLocal extends Application {
  public static void main(String[] args) throws Exception {
//    URL.setURLStreamHandlerFactory(new HandlerFactory());
    launch(args);
  public void start(final Stage stage) throws Exception {
    final FlowPane layout = new FlowPane();
    WebView webView = new WebView();
    webView.getEngine().load("file:///C:\\dev\\gettingstarted\\timeforgotten.html");
//    webView.getEngine().load("jar:file:///C:\\dev\\javafx\\JavaFXidea\\out\\artifacts\\JavaFXidea_jar\\JavaFXidea.jar!/org/jewelsea/examples/webviewlocal/timeforgotten.html");
//    webView.getEngine().load("resource:///org/jewelsea/examples/webviewlocal/timeforgotten.html");
    webView.getEngine().getLoadWorker().exceptionProperty().addListener(new ChangeListener<Throwable>() {
      @Override public void changed(ObservableValue<? extends Throwable> observableValue, Throwable oldThrowable, Throwable newThrowable) {
        System.out.println("Load exception: " + newThrowable);
    // layout the scene.
    layout.getChildren().addAll(webView);
    Scene scene = new Scene(layout, 1000, 600);
    webView.prefWidthProperty().bind(scene.widthProperty());
    webView.prefHeightProperty().bind(scene.heightProperty());
    stage.setScene(scene);
    stage.show();
}which loads the following html file:
<html>
<head>
  <style type="text/css">p { color: sienna; font-size: 20px; text-align: center; }</style>
</head>
<body bgcolor="cornsilk">
<p><em>
    <br/>
    On either side the river lie,<br/>
    Long fields of barley and of rye,<br/>
    And through the fields a road runs by,<br/>
    To many towered Camelot.
</em></p>
<p><img src="camelot.jpg"/></p>
</body>
</html>If you want to test this example the camelot.jpg image is downloadable from http://www.timelessmyths.com/arthurian/gallery/camelot.jpg.
Option 1: The file:// protocol for lookup from the filesystem.
This is the most straight-forward as it is just based on standard html layout in the filesystem - just place your html and it's relative referenced images somewhere in your filesystem in locations relative to each other - if your browser loads it properly, then your webengine will to if you give it the right file:// path.
In the case of file:///C:\\dev\\gettingstarted\\timeforgotten.html, timeforgotten.html is placed in c:\dev\gettingstarted and camelot.jpg image is placed in the same directory.
Option 2: The jar:file:// protocol for lookup from a jar hosted on the filesystem.
This makes use of the http://docs.oracle.com/javase/7/docs/api/java/net/JarURLConnection.html to find your resources.
If your application resources are packaged in a jar file (could be the same jar file as your main application class) then you can reference the jar file through the file protocol, then pick out the resources packaged in the jar file via their relative paths.
Option 3: The resource:// protocol for lookup based on the classpath.
This type of resource lookup is the one most Java programmers are familiar with - a classloader is used to load a resource. The pattern is widely used in web application frameworks on the server. But usually the means to do this is via a classloader.getResource() call, not via a URL.
Java does not, by default, have a URL protocol handler for looking up resources on the classpath, so if you want to do this, it is necessary to create your own protocol and install it.
The installation function is the commented out line: // URL.setURLStreamHandlerFactory(new HandlerFactory());
It is a system wide call for the VM and should be called (just once) before any URL Connections are established.
To get this to work I used a resource handler from http://www.arakhne.org/arakhneVmutils/index.html which included the following classes:
  java.org.arakhne.vmutil.resource.Handler
  java.org.arakhne.vmutil.resource.HandlerFactory
  java.org.arakhne.vmutil.resource.URLConnection
  java.org.arakhne.vmutil.ClassLoaderFinder
  java.org.arakhne.vmutil.Resources
  java.org.arakhne.vmutil.ResourceNotFoundException
  java.org.arakhne.vmutil.URISchemeType
  java.org.arakhne.vmutil.URLHandlerUtilDetails on how all this works are in http://java.sun.com/developer/onlineTraining/protocolhandlers/ which defines "A New Era for Java Protocol Handlers" by defining a URL handler extension mechanism which is hardly ever used.
As a final note to my way overly long forum post, when the WebEngine doesn't process the urls sometimes you can get info on what went wrong via the monitoring the loadWorker's exception property, but sometimes I was able to get more complete stack traces by trying to open a connection on a URL to see if I had got the URL correct - for example:
    URL url = new URL("jar:file:///C:\\dev\\javafx\\JavaFXidea\\out\\artifacts\\JavaFXidea_jar!/org/jewelsea/examples/webviewlocal/timeforgotten.html");
    url.openConnection();Anyway, just using the file:// protocol in webEngine.load() will probably accomplish what you need.
Note that if it is a webstart or browser embedded app, then you'll need to sign it if you want to access the local file system.

Similar Messages

  • How can servlet return the output as html content with drawing picture?

    Does anybody know how can a servlet return the output as html content with drawing picture?
    The drawing picture is drawn at runtime by the servlet.

    Thanks, BalusC.
    But I am not sure if I understand your reply fully.
    From my understanding, you are telling me to first generate a html from a servlet with the image <IMG> tag pointing to a servlet which will be responsible to generate an image?
    For example, <IMG SRC="http://myserver/servlet/testservlet">
    Could you confirm this?

  • HT1459 Just bought a new ipod shuffle for my kid and cannot set it up because it does not show up in itunes. Also the charging light does not light up. what could be wrong, as i am able to see both my iphone and ipad on itunes on the same pc?

    Just bought a new 4th gen iPod Shuffle for my kid. Problem is I cannot do the initial set up, as the device does not show up on iTunes on my PC. Also the charging does not light up. Any ideas on what could be wrong, as I am able to see both my iphone and iPad on iTunes using the same PC?

    I also tried manually underlining a few things on the new iPad and when highlighting a paragraph, it would skip a few lines and the line would go through a few as well. Looks like a major iBooks glitch needs to be addressed here.

  • How to display html content with image in Adobe Flash and Flex mobile project?

    Hi,
      I have a html content with image in it. How to display it in Adobe Flash Builder and Flex mobile project? Which control needs to be used for this?

    Hello,
    The only current way is to use an iFrame, or if you only need some html tags you could use the Text Layout Framework.
    Here this is the iFrame approach:
    http://code.google.com/p/flex-iframe/
    If the swc do not work in Flex4 just use its ource code which works...
    ...it is basically based on this:
    http://www.deitte.com/archives/2008/07/dont_use_iframe.htm
    see also and vote, please:
    http://bugs.adobe.com/jira/browse/SDK-12291
    http://bugs.adobe.com/jira/browse/SDK-13740
    Regards
    Marc

  • HTML content with images and links blocked

    Hello,
    I very much need some help here because my company needs to send out newsletters to our clients in HTML format soon and so far the email with HTML content is being blocked as spam while text content works fine. Specifically, whenever I add a link or an image in HTML content, the email doesn't go through. I tried sending in multipart format but it is also not sending HTML with images and links. Here is my attempt:
                                    props.setProperty("mail.transport.protocol", "smtp");
                                     props.setProperty("mail.host", "mail.server.com");
                                     props.setProperty("mail.user", "joeuser");
                                     Session mailSession = Session.getDefaultInstance(props, null);
                                     mailSession.setDebug(true);
                                     Transport transport = mailSession.getTransport();
                                     MimeMultipart mp = new MimeMultipart("alternative");
                                     MimeBodyPart htmlPart = new MimeBodyPart();
                                     MimeBodyPart textPart = new MimeBodyPart();
                                     textPart.setText("Just to make it multipart");
                                     htmlPart.setHeader("MIME-Version", "1.0");
                                     htmlPart.setHeader("Content-Type", htmlPart.getContentType());
                                     htmlPart.setContent(strHtmlMessage, "text/html");
                                     mp.addBodyPart(textPart);
                                     mp.addBodyPart(htmlPart);
                                     MimeMessage message = new MimeMessage(mailSession);
                                     message.setHeader("MIME-Version", "1.0");
                                     message.setHeader("Content-Type", mp.getContentType());
                                     message.setHeader("X-Mailer", "Recommend-It Mailer V2.03c02");
                                     message.setContent(mp);
                                     message.setSubject(strSubject);
                                     message.setFrom(new InternetAddress("[email protected]"));
                                     message.addRecipient(Message.RecipientType.TO,
                                             new InternetAddress("[email protected]"));
                                             transport.connect();
                                             transport.sendMessage(message,
                                             message.getRecipients(Message.RecipientType.TO));
                                     transport.close();This code is one of my numerous attempts to make HTML send images and links. Please, let me know if there is a workaround way to make JavaMail send HTML with links and images in the message body. Your help will be greatly appreciated.

    The JavaMail FAQ has information on creating HTML messages, including
    messages with both plain text and HTML. Did you find it?
    BTW, your code has many unnecessary statements, such as setting
    the Mime-Version header, which JavaMail will do for you, and setting
    the Content-Type header, which JavaMail does as a side-effect of the
    setContent or setText calls.
    Other than that, it looks like your code should be correctly creating a
    multipart/alternative message. If the recipient is still rejecting it you
    need to figure out what it is about the message that makes the recipient
    think it's spam. Can you send a similar message using another mailer?
    Can you send the message to a different recipient?

  • When I use Firefox to monitor changes I do to HTML files locally, it does not show changes to images unless I restart the browser. Is this a bug?

    I have the local and the remote versions of a page open in two tabs. I change one of the images (keeping the same name in the HTML) and upload the changed image. The tab that shows the remote page only takes a refresh to show the change. The tab showing the local page not. I have tried opening it in a new window but it still does not change. Only if I restart Firefox does it show the change. Why? Is this a bug?

    grantheaslip's suggestion doesn't work for me; no change at all. (Thanks anyway.) Any other ideas? Is there another way to "hard" refresh? I don't see anything in the menu.
    Also, it seems like this is a very recent problem. I thought in the past that a regular refresh did the job.

  • PDF document opened with Preview does not show french accents

    Hi everybody,
    I've got some issues with PDF documents opened with Preview.
    They show a blank space for all the accented vowels.
    If I open the same document with Safari, it's the same. But with Chrome, it works perfectly.
    I assume there's a problem with fonts, but, nothing wrong with fontbook (checked duplicates for instance).
    Last information : it looks ok within chrome on my Imac, but the issue comes back when I try to print from chrome app...the accents are gone on the sheet.
    Any idea ? I don't want to install Adobe reader...
    Thanks for your help !
    http://www.art-shots.net/

    I don't want to install Adobe reader...
    Why not?  It can handle some pdf's that Preview can't.  At least it's worth a try.
    In case you change you mind get it from here.

  • Example file html 5 and jquery does not show in IE

    I used the file mobile starter and made a nice ( its not ready) mobile webpage. The problem is that it is not showing in Internet Explorer not even version 9 . The example file does not show. The site I work on is www.ebblab.nl/qrpage.php
    I know I do not really need IE since its not used in a smartphone but still its feels like a problem because this site will get some links to the big project site.

    Hi
    They removed the back button as a default inclusion in the jQuery mobile beta release as all smart-phones have one built into the system anyway, but it can be re-enabled if you wish, it is in the documentation for the new build, let me know if you have a problem finding it though.
    As for zooming in on the photos have you thought of using the css3  2d transform for this, it is supported in all the modern smart-phones, to get the image to enlarge by 2x you would use the hover/focus pseudo-class and then scale by 2.?
    img:hover, img:focus {
    transform: scale(2.0);
    You would have to use the vendor prefixes for each browser as well.
    PZ

  • FF5 does not show images that are 'moved permanently' (http response 301)

    Our web app shows maps from OpenStreetmap. The webapp is secure, that is, is uses HTTPS. Now, IE complains horribly when the web page tries to load <img> via HTTP, because it's mixed content that that is considered baad.
    So our webapp serves the images by responding via HTTPS with a 301 (moved permanently) to the real OpenStreetmap URL (with is HTTP). That fools IE to not complain.
    Now, Firefox 5 suddenly does not show the map images AT ALL. This has worked beautifully with previous version (and all other browsers).
    What's wrong?

    I fixed the problem.  (YAY!)
    It was the way I embedded the files -- the Dreamweaver default does not work properly so I used the embed from this generator: http://www.bobbyvandersluis.com/swfobject/generator/index.html#alternativeContentHelp which now lets my navbar and swfobjects load properly.  I also made sure that my slideshow (loader.swf) was set with wmode = opaque while the navbar is set to wmode = transparent.  The div for the nav bar has z-index set to 5 while the div for the slideshow has z-index set to 1.  Both have absolute positioning.  I hope this helps anyone in the future that has trouble with overlaying flash (.swf) files.
    Thanks for your reply and trying to help me solve this issue!

  • Muse 7.0 plus Chrome: browser does not show images full browser width

    Hi there,
    I have a serious problem with the latest Muse version: the images which I use as parallax-masks for the background won't work with Chrome, though Safari and Firefox are not showing any problems. The issue: Chrome does either not scale the images to 100% browser-width or does not show them at all, or even shows the images cut into narrow stripes. This problem did not show in the previous version of Muse.
    Of course I already restarted application and computer. System: Mac OSX Mavericks.
    What to do now? The presentation with the client is very soon and this bug makes me very nervous.
    Best,
    bartl

    The problem bartl encountered and reported was fixed by the 7.1 release (November 21st). The problem you're describing sounds different.
    As of yet, I'm unable to reproduce what you're describing. The URL you've provided views the same in all the browsers I've tried, Chrome (32.0.1700.77) and non-Chrome, Mac and Windows.
    That said, looking at your master page I don't think you've created what you intended. At present there are two full screen slideshows on your A-master. On contains no images and the other contains a single image. Both are set to have thumbnails and the thumbnails container is off the right side of the page.
    If you look at your "Master Slideshow" layer in the Layers panel, you'll see the two slideshows. I think you'll want to delete one of them and, given your design, turn off thumbnails for the remaining one.
    Also, if you don't plan to have multiple images in the full screen slideshow, you'd be better off using a background fill image rather than the slideshow widget.
    I remain a bit puzzled how/why you're seeing different behavior in your instance of Chrome. Have you cleared your browser cache?
    On an unrelated note, if you set the page fill and stroke to none and set the browser fill to the most common color from the garage door image, it will avoid the momentary appearance of a white page on a grey background when your home page first loads. Instead the site visitor would see a blank page that's the most common color from the slideshow image, until that image loads.

  • Content Tree Media Folder Not Showing Images

    I have below issue with getting the uploaded images under Media tree section in Content Tree. Please see if you can help me to figure out the issue.
    I did below configuration in Admin section for Tree same as avispots site.
    Title:
    Media
    Tooltip:
    Media
    Sites:
    avisports
    My_Site
    Required Roles:
    SiteAdmin, SitesUser, GeneralAdmin
    Tab Contents:
    My Image Asset
    Image Category
    Image
    ID:
    1336168677350
    My asset name is "My Image Asset". Though I am able to upload and see the images of type "My Image Asset" and Image type, I am not able to see them in the content tree. If I double click on Media it
    shows all images in browsing screen (same as after search) however it does not show them under the Media folder as shown in avisports site.

    Interesting, I'm getting the same thing.  I know for a fact, all of my music that I had album artwork for used to show the album art in Finder.  Admittedly, I don't know when this changed, as I haven't checked for a while (pre-mavericks).  One thing I did notice just now, though, is the album art does show for music purchased through iTunes.  It doesn't show for music that I have imported.  This didn't used to be the case...

  • Photoshop does not show Image after converting to sRGB

    Hey,
    i just got a new Eizo Coloredge Monitor which i conectetd to my Macintosh.
    Everything seems to be fine actually.  But when i´m converting an Image from Pro Photo to sRGB for instance... the Photoshop Window does just show a black window.
    I think it is just some kinda new function or some kinda Colorspace warning, but i just dont get around it and don´t really know what this means..
    Can someone help me .. or maybe had the same problem??
    best,
    max

    Are you stating when you use edit Convert to Profile abe in the convert dialog you check preview the change the profile to convert to different profiles like sRGB or sgray and others that you see a black image window with no image in it?

  • Trying to create Mouse over effect with more than one show image appearing in same cell

    Firstly this is the link to my test page: http://www.design39.co.uk/indexhope.html
    If you roll your cursor over the top left logo (the D&S) one it displays an image to the left. If you roll your cursor onto the next logo (Netnotts) it fades away again. Great. Exactly what I wanted and created in CSS (well done me as I don't normally do much with CSS but the new CS4 has very forced it).
    What I am trying to create is: When you roll onto the Netnotts logo, not only does the original image to the left disappear but a new relative one appears, this is to be for all the logos. In CSS I can only create it as far as I can. I have thought about using AP DIV tags to do it which would obviously work but to keep it in the right place, I would then have to align my whole website to the left instead of centered like it is and to be fair, that's not particularly pleasing to the eye as this is my own portfolio of work.
    I can do flash  to make 'pretty things' but have no idea about actionscript and java is way over my head but I am sure with some help I would be able to get it together as the that particular effect, although done in CSS, is running javascript I noticed.
    Many thanks in advance.

    A relative positioned layer? does this mean it knows how far to be away from the table as a pose to an absolute positioned layer which is lay 15px from the left? I need to be able to keep the positioning as its key, cant have the layer popping up in different places pending on the users browser size.
    I posted the question on a few forums and I got the following back: http://www.design39.co.uk/bla.html
    which is exactly what i wanted it to do but have no idea how to insert java script into my page; Further more, that was done in layers not table cells.
    Any ideas?

  • Bridge does not show image previews anymore on one of my drives

    Bridge isn't showing image previews on one of my drives. I have tried resetting the preferences as well as deleting the cache to no avail.

    I don't believe so, because it operates as expected in finder. It's only bridge that doesn't seem to want to create the thumbnails. I went to the thread you posted, Robert, but unfortunately I'm not on Windows and don't see any "online" or "offline" options.
    Transporter is not a cloud service. It's actually a local hardware device, so it's more a network drive than anything else.

  • Mail does not show images anymore server stopped responding on my iPad 2 when attempting to browse web

    Over the last couple of days my ipad 2 has started to play up. First the mail would not show images in mail then when trying to browse the web it now will not open any pages. I have attempted a wipe & reload but still no difference.

    Have you tried restarting or resetting your iPad?
    Restart: Press On/Off button until the Slide to Power Off slider appears, select Slide to Power Off and, after It shuts down, press the On/Off button until the Apple logo appears.
    Reset: Press the Home and On/Off buttons at the same time and hold them until the Apple logo appears (about 10 seconds).

Maybe you are looking for

  • Parse a SAML assertion

    I want to parse a SAML assertion from an Identity Provider and use some of the data for identity injection. Anyway, the java identity injection plug-in can not access the SAML assertion, it can only access the username and password using the External

  • Permissions problem - unable to write to external drive

    I have 2 x 2TB external drives connected to which I have been manually copying media from other drives with mixed content. The same content has been copied to both from other drives of mixed content - drives 1 and 2 are manual copies of each other. I

  • Leopard compatibility on older G4 macs

    I have 5 macs of various vintages. 2 G4 cubes, 1 G4 Titanium notebook, 1 G4 tower that all came with OS X 10.1 and one 17" iMac that came with OS X 10.2 Jaguar. It would seem that according to the specs on Leopard, my Macs will not run 10.5. So what

  • Reg : Sending Binary data as output in GP

    Hello , I developed one webdynpro Project it has interactive adobe form ,  in Guided procedures created CO for Webdynpro Componet(GP interface) for this form and created GP inerface also. But in this callable object the Requestor creates new pdf form

  • Remove password for development mode

    Is there a way to be in development mode and not have password set up? Z10 is my primary phone, and it annoys me that I MUST have password on whenever I am in development mode. Can I be in dev mode without a password? It would make my life a bit easi