There are not many opportunities to use COM components in JSP programs, and JSP does not directly operate COM functions, but some work must also use COM components to complete, the following is the specific method of operation.
There are two ways to use a COM component in a JSP: one that is controlled by JavaScript on the client side (strictly speaking this should be HTML functionality), such as:
<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;
}
</scipt>
The result returns: Hello, Li Zongbin
But the disadvantage of this approach is that you can only operate on the client side and not the server. And each client has to install this component to run.
The second is to operate the server-side COM components directly using JSP via java-com to connect the bridge Jacob. Jacob's download address is http://danadler.com/jacob/. Two files are required to run: Jacob.jar and Jacob.dll.
The way to configure it is to put the Jacob.jar in the classpath and add the path where Jacob.dll is located. such as d:\com
The following methods are used:
1. Register the COM component on the server side first;
2. Find the name of the component (generally should be known, do not know if you go to the registry to find);
3. program Example:
<%@ page contenttype= "text/html charset=gb2312" language= "Java"%>
<%@ page import= "COM.JACOB.C" om.* '%>
<%@ page import= ' com.jacob.activex.* '%>
<%
System.runfinalizersonexit (true);
activexcomponent MF = new Activexcomponent ("Makercom.makerext");//Find component
object mycom = Mf.getobject ();// Generates an object
string result= dispatch.call (mycom, "Hello", New Variant ("Li Zongbin"))
/* method to invoke the component, Mycom is the object name of the component, Hello is the function of the component, the new Variant ("Li Zongbin") is the parameter variable of the component, if there are multiple can be added at the back, method consistent */
Out.println (result);
%>