Using COM components in a JSP program

Source: Internet
Author: User
Tags client
js| program in the JSP program to use COM components, there is not much chance, JSP also does not directly operate COM functions, but some work must also use COM components to complete, the following is the specific operation method.
There are two ways to use a COM component in a JSP:
One is the use of JavaScript in the client to control (strictly speaking this should be the function of HTML), 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.com.*"%>
<%@ page import= "com.jacob.activex.*"%>
<%
System.runfinalizersonexit (TRUE);
activexcomponent MF = new Activexcomponent ("Makercom.makerext");//Find Component
Object mycom = Mf.getobject ();
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, the method is consistent.
OUT.PRINTLN (result);
%>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.