Problems with JCo in JSP

I've a problem to import the jCO.jar file in my JSP file. I've developed a JavaBean which called a BAPI to connect to the SAP R/3 system. However, I don't know how to write my JSP file to implement the System.out.println... sentences in the JavaBean.


    Requires Free Membership to View

    When you register, you will start receiving targeted emails from my award-winning team of editorial writers. Our goal is to keep you informed on the hottest topics and biggest challenges faced by SAP professionals today.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSAP.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSAP.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

Without having access to your code, I can't offer a definitive answer for you. However, I can give you some tips to get you looking in the right direction.

Make sure you have this statement at the top of your JSP (Java Server Page):

<%@page import="com.sap.mw.jco.*"%> This ensures that you will have access to the libraries contained within jco.jar (or sapjco.jar, if you are using a newer version). Also, make sure that jco.jar is in the CLASSPATH used by your application server. This means that where ever you set the CLASSPATH, whether in your autoexec.bat, sy tem variables, or in the startup of your application server, part of that path must look like this:

CLASSPATH=c:jcojco.jar;%CLASSPATH%

Finally, if you are storing data in a JavaBean that must be displayed in your JSP, use get/set methods in the JavaBean to retrieve that data. A 'System.out.println' in your JavaBean will not display in your JSP, as these statements are caught by the Java Virtual Machine and displayed in the JVM's command console window. Use a statement such as:

<%= myJavaBean.getSomeInfo() %>

To display text within your Java Server Page.


This was first published in July 2002