Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you're using JSP as view technology, you can use the <a href="http://download.oracle.com/docs/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/" rel="nofollow noreferrer">JSTL</a> <a href="http://download.oracle.com/docs/cd/E17802_01/products/products/jsp/jstl/1.1/docs/tlddocs/c/import.html" rel="nofollow noreferrer"><code>&lt;c:import&gt;</code></a> for this. It's as simple as</p> <pre><code>&lt;c:import url="http://example.com/service" /&gt; </code></pre> <p>It however doesn't run in sync with JSF as you'd expect from the coding. Also, this is not supported in Facelets. So if you want to render/display it conditionally (and thus run in sync with JSF) or are using Facelets, then you'll have to do this in the managed bean. To start, you can use <a href="http://download.oracle.com/javase/6/docs/api/java/net/URL.html" rel="nofollow noreferrer"><code>java.net.URL</code></a> and consorts to get content from an URL.</p> <pre><code>InputStream input = new URL("http://example.com/service").openStream(); Reader reader = new InputStreamReader(input, "UTF-8"); // You may want to verify charset based on response headers. StringBuilder builder = new StringBuilder(); for (int data; (data = reader.read()) &gt; -1;) { builder.append((char) data); } String result = builder.toString(); </code></pre> <p>Put this in the constructor or action method, depending on the conditions it needs to execute. You can however also wrap this all in flavor of a standalone custom/composite component or EL function.</p> <h3>Related questions:</h3> <ul> <li><a href="https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests">How to use java.net.URLConnection to fire and handle HTTP requests?</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload