%@ page import="com.kesoftware.imu.*" %> <% /* * Create new session object. */ Session imuSession = new Session(); imuSession.setHost("imu.mel.kesoftware.com"); /* * Work out what port to connect to. */ int port = 40136; if (request.getParameter("port") != null) port = Integer.parseInt(request.getParameter("port")); imuSession.setPort(port); // example-2 /* * Establish connection and tell the server we may want to re-connect. */ imuSession.connect(); imuSession.setSuspend(true); // example-3 /* * Create module object and tell the server not to destroy it. */ Module module = new Module("eparties", imuSession); module.setDestroy(false); // example-4 /* If name is supplied, do new search. The search term is passed from * example.html using GET. */ if (request.getParameter("name") != null) { Terms terms = new Terms(TermsKind.OR); terms.add("NamLast", request.getParameter("name")); module.findTerms(terms); } /* * Otherwise, if id is supplied reattach to existing server-side object. */ else if (request.getParameter("id") != null) { module.setID(request.getParameter("id")); } /* * Otherwise, we can't process. */ else { throw new Exception("no name or id"); } // example-5 String[] columns = { "NamFirst", "NamLast" }; // example-6 /* * Work out which block of records to fetch. */ int rownum = 1; if (request.getParameter("rownum") != null) rownum = Integer.parseInt(request.getParameter("rownum")); // example-7 /* * Fetch next five records */ ModuleFetchResult result = module.fetch("start", (rownum - 1), 5, columns); long hits = result.getHits(); /* * Save rows in convenient variable for later use. */ Map[] rows = result.getRows(); /* * Build the results page */ %>
Number of matches: <% out.print(hits); %>
| " + num.toString() + " | "); out.println("\t" + row.getString("NamFirst") + " " + row.getString("NamLast") + " | "); } %>