There are not many opportunities to use com components in jsp programs, and jsp does not directly operate on com functions, but sometimes some work must be completed using com components, the following describes the specific operation methods.
There are two methods to use com components in jsp: one is to use javascript to control on the client (strictly speaking, this should be an html function), such:
<OBJECT id = "myCom" classid = "clsid: 9D8A2E2F-D38F-CDAC-D0C5-5B3FB2275442" codebase = ". com/com. cab # version = 1.9.9.0">
</OBJECT>
<Script>
Function Hello (){
Var result = myCom. Hello ("Li zongbin");
Return result;
}
</Scept>
Return result: Hello, Li zongbin
However, this method has the disadvantage that it can only be operated on the client, but not on the server. In addition, each client must install this component before it can run.
The second is to directly use jsp to connect to JACOB bridge through Java-COM to operate the com component on the server. JACOB's website is http://danadler.com/jakb /. Two files are required for running: jacob. jar and jacob. dll.
The configuration method is: Put jacob. jar in CLASSPATH and add the path of jacob. dll to path. Such as d: \ com
The method is as follows:
1. Register com components on the server first;
2. Find the component name (generally known, go to the registry if you do not know );
3. Program example:
<% @ Page contentType = "text/html; charset = gb2312" language = "java" %>
<% @ Page import = "com.jacb.com. *" %>
<% @ Page import = "com. jacob. activeX. *" %>
<%
System. runFinalizersOnExit (true );
ActiveXComponent mf = new ActiveXComponent ("MakerCom. MakerExt"); // locate the component
Object myCom = mf. getObject (); // generate an Object
String result = Dispatch. call (myCom, "Hello", new Variant ("Li zongbin "));
/* Call the component method. myCom is the Component Object Name, Hello is the component function, and new Variant ("Li zongbin") is the component parameter variable, if there are multiple, you can add them at the back end. The method is the same */
Out. println (result );
%>