Manage Learn to apply best practices and optimize your operations.

Retrieve richtext field as HTML

Retrieve richtext field as HTML

Building a Domino Web application sometimes requires you to generate the HTML code for a page using an agent to retrieve data and using the agentContext to return it to the browser. If your richtext field contains an inline picture, you will not be able to use GetItemValueString to include the image. To work around this, place two tags, before and after the richtext field, let's call it <HTMLBody> and </HTMLBody> respectively. You will have to provide the document url to the getHTMLContent function and it will return the true HTML code and that you can use in your application.

import java.net.*;
import java.io.*;

public class HTMLReader {
	
	public String getHTMLContent( String docURL )  {
		
		String startstring = "<HTMLBody>";
		String endstring = "</HTMLBody>";
		
		String strHTML = "";	// to hold the HTML to return
		
		try {
			URL noteURL = new URL(docURL);
			URLConnection con = noteURL.openConnection();
			BufferedReader in = new BufferedReader ( new InputStreamReader 
( con.getInputStream() ) ); String inputLine; while ((inputLine = in.readLine()) != null) strHTML = strHTML + inputLine; in.close(); // strip down the HTML between the delimeters int startindex = strHTML.indexOf(startstring) + startstring.length(); int endindex = strHTML.indexOf(endstring); strHTML = strHTML.substring(startindex,endindex); } catch ( Exception e ) { System.out.println("Error at URLConnectionReader"); e.printStackTrace(); } return(strHTML); } }

Dig Deeper on Lotus Notes Domino Administration Tools

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close