[opencms-dev] including external content without frames and iframes

Joachim Arrasz info at arrasz.de
Wed Oct 27 12:48:57 CEST 2004


Hi,

>Is there a possibility to do this? Probably parsing this page and stripping
>everything but the "<body>body content</body>" of this page?
>
>  
>
we did something like this with just using the Commons-HttpClient and 
then included this response into the JSP ...

Is this what you need?

Snippet fpr HttpClient-Usage:

// Create an instance of HttpClient.
        HttpClient client = new HttpClient();
        String url = "http://www.synyx.de";
        // Create a method instance.
        GetMethod method = new GetMethod(url);
       
        // Provide custom retry handler is necessary
        DefaultMethodRetryHandler retryhandler = new 
DefaultMethodRetryHandler();
        retryhandler.setRequestSentRetryEnabled(false);
        retryhandler.setRetryCount(3);
        method.setMethodRetryHandler(retryhandler);
       
        try {
            // Execute the method.
            int statusCode = client.executeMethod(method);
           
            if (statusCode != HttpStatus.SC_OK) {
                System.err.println("Method failed: " + 
method.getStatusLine());
            }
           
            // Read the response body.
            byte[] responseBody = method.getResponseBody();
           
            // Deal with the response.
            // Use caution: ensure correct character encoding and is not 
binary data
            System.out.println(new String(responseBody));
           
        } finally {
            // Release the connection.
            method.releaseConnection();
        }

Hope this helps ...

Bye  Joachim Arrasz

Synyx oHG


-- 
/**
* @author Joachim Arrasz 
* --> head of technology research <--
* @phone +49/(0)721/66487932
* @mobile 0160/8021351
* @mail arrasz at synyx.de
* @url http://www.synyx.de
*/
 




More information about the opencms-dev mailing list