Thursday, September 19, 2013

Re: Call external images/video/other resources from external folder with (embebbed) jetty from GWT

Ok, you're right in :
 You probably need getHostPageBaseURL, which is the "folder" in which your HTML page (which loads the *.nocache.js file) lives.

And:

Also, those methods return a value that ends in "/", so you don't need to append "/" to it: GWT.getHostPageBaseURL() + "folder_name_of_static_resources/the_image.jpg"

BUT, it still does not works:

Code:

DivElement outerSpaceImage = DOM.getElementById("outerSpaceImage").cast();
Element img = DOM.createImg();
img.setAttribute("src", GWT.getHostPageBaseURL()+"folder_name_of_the_static_resources/image/the_image.jpg");
outerSpaceImage.appendChild(img);


XML (modified):

<Configure id="sample" class="org.mortbay.jetty.webapp.WebAppContext">

<Array id="plusConfig" type="java.lang.String">
<Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
<Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>


<New id="handler" class="org.mortbay.jetty.handler.ContextHandler">
<Set name="contextPath">/folder_name_of_the_static_resources</Set>
<Set name="resourceBase">/real/filesystem/path/to/static/resources/</Set>
<Set name="handler">
<New class="org.mortbay.jetty.handler.ResourceHandler">
<Set name="cacheControl">max-age=3600,public</Set>
</New>
</Set>
</New>
</Configure>



Error:


[WARN] 404 - GET /folder_name_of_static_resources/image/the_image.jpg (127.0.0.1) 1436 bytes
   Request headers
      Host: 127.0.0.1:8888
      Connection: keep-alive
      Accept: image/webp,*/*;q=0.8
      User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
      Accept-Encoding: gzip,deflate,sdch
      Accept-Language: en-US,en;q=0.8
      Cookie: JSESSIONID=1fgoy48j2k9md
   Response headers
      Content-Type: text/html; charset=iso-8859-1
      Content-Length: 1436


So, same error is present =(





--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment