UniObjectsJSP
From Pickwiki
Jump to navigationJump to search
Here's the JSP version of the same old test program... can anyone convert it to ASP??
<%@ page import="asjava.uniobjects.*,asjava.uniclientlibs.*" %> <% [[UniFile]] customerFile; [[UniString]] uString; [[UniJava]] uJava = new [[UniJava]](); out.println("Version number = " + uJava.get[[VersionNumber]]()); out.println("Max Sessions = " + uJava.get[[MaxSessions]]()); out.println("Num Sessions = " + uJava.get[[NumSessions]]()); try { // every thing runs out of the [[UniSession]] instance. [[UniSession]] uSession = new [[UniSession]](); out.println("after openSession"); out.println("Status = " + uSession.status()); /[[/Set]] up variables. uSession.set[[HostName]]("[[YOUR_HOST_NAME]]"); uSession.set[[UserName]]("[[YOUR_USER_NAME]]"); uSession.setPassword("[[YOUR_PASSWORD]]"); /[[/You]] don't need the next line on [[UniData]], where you //cannot change the port number. However, if you are //on [[UniVerse]] and have changed the port number from the //default value of 31438, then uncomment this line edit it //to contain your port number. //uSession.set[[HostPort]]("YOUR PORT HERE"); /[[/This]] is the place you go to type 'uv' or 'udt' /[[/Example]]: /usr/ud60/demo uSession.set[[AccountPath]]("/usr/ud60/demo"); //you may not need this... //it might need to be 'uvcs' for [[UniVerse]] (??) //uSession.set[[ConnectionString]]("udcs"); /[[/Uncomment]] the next three lines and change the values //if you're using a proxy. /[[/Ignore]] the part of the UOJ manual that tries to convince //you that you need it. Unless you're using applets, //chances are, you do NOT need the proxy. //uSession.set[[ProxyPort]](1234); //uSession.set[[ProxyHost]]("PROXY HOST"); //uSession.set[[ProxyToken]]("PROXY TOKEN(PASSWORD)"); out.println ( "[[HostName]]: "+uSession.get[[HostName]]() ); out.println ( "[[HostPort]]: "+uSession.get[[HostPort]]() ); out.println ( "[[UserName]]: "+uSession.get[[UserName]]() ); out.println ( "[[AccountPath]]: "+uSession.get[[AccountPath]]() ); out.println ( "[[ConnectionString]]: "+uSession.get[[ConnectionString]]() ); out.println(); out.println ( "[[ProxyPort]]: "+uSession.get[[ProxyPort]]() ); out.println ( "[[ProxyHost]]: "+uSession.get[[ProxyHost]]() ); out.println ( "[[ProxyToken]]: "+uSession.get[[ProxyToken]]() ); // lets connect to the database. uSession.connect(); out.println("Connected!"); /[[/This]] next section is file-structure specific. /[[/Change]] to one of your filenames if you're not using the demo account customerFile = uSession.open("CUSTOMER"); out.println("CUSTOMER opened"); out.println (customerFile.toString()); /[[/Change]] this to a key in the file you specified String key = "25"; uString = customerFile.read(key); out.println(uString); /[[/Some]] examples of [[UniDynArray]] and read[[NamedField]] [[UniDynArray]] u[[DynArray]] = new [[UniDynArray]](uString); out.println("Customer Name = " + u[[DynArray]].extract(1) + "\n"); out.println(); String fieldName = "CITY"; [[UniString]] fieldContents = customerFile.read[[NamedField]](key, fieldName); out.println(fieldName+": "+fieldContents); customerFile.close(); out.println("CUSTOMER closed"); // did we connect? if (uSession.isActive()) { // lets disconnect from the database. uSession.disconnect(); } out.println("Disconnected."); } catch ([[UniSessionException]] e) { out.println("Error: " + e); } catch ([[UniFileException]] e) { out.println("File Error: " + e); } %>