Difference between revisions of "Example datanavigation jssp"

From Lianjapedia
Jump to: navigation, search
Line 3: Line 3:
  
 
==Description==
 
==Description==
Example JavaScript Server Page (.jssp) script.
+
Example JavaScript Server Page (.jssp page).
  
 
==Code==
 
==Code==

Revision as of 05:50, 3 September 2013

Name

example.jssp

Description

Example JavaScript Server Page (.jssp page).

Code

<%@ Language=JavaScript %>
<html>
<body>
<%
	// Note that just as in PHP, JavaScript Server Pages can use include_once(filename) and include(filename)
	// The path of the filename is relative to the directory containing this script.
	include_once("library_example.js");
 
	// The Lianja global object provides embedded database access
	db = Lianja.openDatabase("southwind");
	print("<br>");
 
	// Lianja.openDatabase() returns a Database object so now we can open a RecordSet
	rs = db.openRecordSet("select * from customers");
	print("<br>");
	print("Fieldcount="+rs.fieldcount);
	print("<br>");
%>
<table>
<%
	print("<tr>");
	for (i=0; i<rs.fieldcount; ++i)
	{
		print("<td>"+rs.field(i).name+"</td>");
	}
	print("</tr>");
	rs.moveFirst();
	for (j=0; j<rs.reccount; ++j)
	{
		print("<tr valign='top'>");
		for (i=0; i<rs.fieldcount; ++i)
		{
			print("<td>"+rs.field(i).value+"</td>");
		}
		print("</tr>");
		rs.moveNext();
	}
	rs.close();
	db.close();
%>
</table>
</body>
</html>