Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you invoke LAPI thru a JSP?

LAPI/Servlet/JSP

How do you invoke LAPI thru a JSP?

by  appnair  Posted    (Edited  )
It is easy to use LAPI in the context of a servlet/jsp so long as you have mastered the class path settings on your web server running a servlet engine.Needless to say you would have to use a j2ee compliant servlet engine.In the example below I show the typical enterprise access LAPI being used thru a JSP.I also have included some custom JSP code that will debug your application class path to a certain extent.The page is not aesthetic but will serve the needs of a novice programmer wanting to extend LAPi thru servlet/jsp.For this example I have used the iPlanet 6.0 web server running on a win2k machine with jdk 1.3.My livelink install also runs on the same machine albeit a different port.The LAPI classes are set on my computer's class path as well as the web server's classpath.
A note of caution:Before emabarking on severe debugging pls run a console LAPi sample and see if you can get some results.JSP/servlet apache/tomcat errors are so verbose and can be quite unsettling.use common sense to a great extent.ErrorAccessingEnterprise.jsp calls LLEnterprise.jsp which is the meat of livelink calls.I made this like this so you can comment out that in case this does not compile too well.I havenot tried this with a apache/TOMcat combination but I'm sure this should work since the servlet engine in Iplanet is the official TOMcat implemention.

[color green]listing of ErrorAccessingEnterprise.jsp[/color]
[color red]
<%@ page language="java" %>
<%@ page import="java.util.*,javax.servlet.*,javax.servlet.jsp.*,java.sql.*,java.io.*"%>

<!-- Make sure the LAPI classes are available to the servlet engine
Setting classpath on your server does not automatically ensure
availabilty of this class to the web server
For ease I have put in some code that will show
you your web server's application classpath
-->
<%@ page import="com.opentext.api.* "%>
<html>
<head>
<title>Accessing Enterprise WorkSpace for the Impatient</title>
</head>
<body>

<b><H2>Disclaimer</b></h2>
<li>This is not a JSP/Servlet tutorial. If you need one this is a <a href="http://www.jsptut.com" target="newin"> good </a> site
<li>The author assumes that the users understand such terms
as classpath,servlet,server,client,LAPI for java
<li>This shows a very rudimentary version of a JSP file
accessing the livelink system

<h4>This page was tested on Iplanet6.0 on Windows 2000
</h4>
If the page worked the output should look something like<p> This however is not JSP but HTML<p>
<b>Enterprise ID: 2000 Enterprise Volume: -2000 Accessing.......0
Listing....0 Number is..4 The object is a ..-110starting enumeration
VOLUMEID ID PARENTID USERID GROUPID USERPERM GROUPPERM WORLDPERM SYSTEMPERM PERMID NAME TYPE SUBTYPE COMMENT CATEGORY CREATEDATE MODIFYDATE EXATT1 RESERVED RESERVEDBY RESERVEDDATE ORDERING CHILDCOUNT VERSIONNUM ASSIGNEDTO STATUS PRIORITY GIF CATALOG FILENAME FILETYPE DATASIZE RESSIZE MIMETYPE OWNERNAME ORIGINDATAID Permissions </b></h2>
as you can see this is the column info of dtree table<p>
<b>if page does not work as intended check a few things</b>>
<li>Did the page compile Check your _jsps folder for a class file of same name as this file?
<li>Is the LAPI classes available to the server
<li>Did you edit the connection parameter's appropriately
<li>Did the below jsp code show you your application's classpath and is the LAPI classes in them?</B></H4>
<H3>Web Server's Application ClassPath</H3>


Going to include LLEnterprise.jsp which really is the LAPI classes in action...<BR>


<%@ include file="LLEnterprise.jsp" %>



</body>

</html>
[/color]

[color green]listing of LLEnterprise.jsp[/color]

[color teal]

<%
//debugging available classes avail to web server
final String DELIMITER = System.getProperty("path.separator");
StringTokenizer st;
String path,token;
path = System.getProperty("java.class.path");
st = new StringTokenizer(path, DELIMITER);
while (st.hasMoreTokens()) {
token = st.nextToken();
out.println(token);
}
%>

<%
//actual livelink stuff

int ErrStatus; //to hold error number of API message
String DFT = ""; //Default database conn.Default systems should work without anything
String User = "Admin"; //username
String Pass = "123admin"; //passwd
String Server = "localhost"; //livelink host
int Port = 5556; //livelink server port see opentext.ini
LLSession mySession;//create a session object
LAPI_DOCUMENTS myDoc;//create a document api object
LLValue value = new LLValue();//create an LLValue object to store Ent volid
//once we are in enterprise we will show some things
LLNameEnumeration enumName;
String eNName;
int volID, objID;//self explanatory
//pass relevant connection details to the session object
mySession=new LLSession (Server, Port, DFT, User, Pass);

//handler to DocAPI

myDoc =new LAPI_DOCUMENTS (mySession);

//Access the Enterprise
if (myDoc.AccessEnterpriseWS(value) == 0)
{
System.out.println("Enterprise Accessed Successfully");
//Extract the Enterprise Volume and Object ID's and display them.
objID = value.toInteger("ID");
volID = value.toInteger("VolumeID");
out.println("Enterprise ID: " + objID);
out.println("Enterprise Volume: " + volID);
out.println("Accessing......." + myDoc.AccessEnterpriseWS(value) + "<br>");
//String query = "subType = " + LAPI_DOCUMENTS.DOCUMENTSUBTYPE;//if you want to limit the objects that you are seeking
out.println("Listing...." + myDoc.ListObjects(volID, objID, null, null, LAPI_DOCUMENTS.PERM_SEE, value));
out.println("Number is.." + value.size());
out.println("The object is a .." + value.type()+"starting enumeration");
out.println("<br>");
enumName=value.enumerateNames();
while(enumName.hasMoreElements()){
eNName = enumName.nextElement().toString();
out.println(eNName);
}

}
else
{
ErrStatus = mySession.getStatus();
String statusMessage = mySession.getStatusMessage();
String apiError = mySession.getApiError();
String errMsg = mySession.getErrMsg();
out.println("statusMessage : "+statusMessage);
out.println("apiError : "+apiError);
out.println("errMsg : "+errMsg);
}


%>
[/color]



Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top