In JSPProgramThere are not many opportunities to use COM components in. jsp does not directly operate 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 object name of the component, hello is the component function, and new variant ("Li zongbin") is the component's parameter variable. If there are multiple variables, you can add them to the back and use the same method. */
out. println (result);
%>