There are not many opportunities to use COM components in JSP programs. JSP does not directly operate COM functions, but some must have to use COM components.
There are two ways to use COM components in JSP:
One is to control the client with JavaScript (strictly said that this should be HTML function), such as:
Object>
Function Hello () {
Var result = mycom.Hello ("Li Zongbin");
Return Result;
}
scipt>
The result is returned: Hello, Li Zongbin
However, this method has a drawback that it can only be operated in the client, and the server is not operating. And each client is to install this component to run.
The second is to use JSP to operate server-side COM components with JAVA-COM connection Jacob. Jacob's download address is
http://danadler.com/jacob/. Two files are required when running: Jacob.jar and Jacob.dll.
The configuration method is: put Jacob.jar in the classpath and add the path where Jacob.dll is located to the path. D: / COM
The method used is as follows:
1. First register your COM component first on the server;
2. Find the name of the component (generally should know, if you don't know, you will go to the registry);
3. Example:
<% @ page contenttype = "text / html; charset = GB2312" Language = "java"%>
<% @ Page Import = "com.jacob.com. *"%>
<% @ Page Import = "com.jacob.activex. *"%>
<%
System.RunfinalizersoneXIT (TRUE);
ActiveXComponent Mf = New ActiveXComponent ("Makercom.makerext"); / / Find components
Object mycom = mf.getObject (); // Generate an object
String result = dispatch.call (Mycom, "Hello", New Variant ("Li Zongbin");
/ * Method for calling the component, Mycom is the object name of the component, Hello is the function of the component, New Variant ("Li Zongbin") is the parameter variable of the component, if there are multiple, the method is uniform * /
Out.println (Result);
%>