Use COM components in JSP programs

Source: Internet
Author: User

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);
%>

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.