[sword-cvs] swordweb/examples lookup.jsp,NONE,1.1 search.jsp,NONE,1.1

sword@www.crosswire.org sword@www.crosswire.org
Thu, 8 Apr 2004 17:35:32 -0700


Update of /cvs/core/swordweb/examples
In directory www:/tmp/cvs-serv7951/examples

Added Files:
	lookup.jsp search.jsp 
Log Message:
Added a couple simple examples


--- NEW FILE: lookup.jsp ---
<%@ page
    language="java"
    contentType="text/html;charset=utf-8"
%>

<%@ page import="org.crosswire.sword.orb.*" %>



<%
	SWMgr mgr = SwordOrb.getSWMgrInstance(session);
	SWModule book = mgr.getModuleByName("KJV");
%>

<html>
<body>

<h1>SWORDWeb Lookup Example</h1>

<%
	book.setKeyText("jn3:16");
%>
<p>The <%= book.getDescription() %>'s entry for <%= book.getKeyText() %> is:</p>
<p><%= new String(book.getRenderText().getBytes(), "UTF-8") %></p>


</body>
</html>

--- NEW FILE: search.jsp ---
<%@ page
    language="java"
    contentType="text/html;charset=utf-8"
%>

<%@ page import="org.crosswire.sword.orb.*" %>



<%
	SWMgr mgr = SwordOrb.getSWMgrInstance(session);
	SWModule book = mgr.getModuleByName("KJV");
%>

<html>
<body>

<h1>SWORDWeb Search Example</h1>

<%
	String searchTerm = "God love world";
	SearchType searchType = SearchType.MULTIWORD;
	int searchOptions = 2;	// 2=ignore case. cheezy, should be a define
	String searchRange = "";  // use anything intelligible, eg. "mat-joh5;acts"

	SearchHit[] results = book.search(searchTerm, searchType, searchOptions, searchRange);
%>

<p> There are <%= results.length %> results searching for "<%= searchTerm %>" in <%= book.getName() %></p>
<table border="1">
<tr><td>Reference</td><td>Text</td></tr>

<%
	for (int i = 0; i < results.length && i < 100; i++) {
		book.setKeyText(results[i].key);
%>

<tr><td><%= book.getKeyText() %></td><td><%= new String(book.getRenderText().getBytes(), "UTF-8") %></td></tr>

<%
	}
%>

</table>


</body>
</html>