cancel
Showing results for 
Search instead for 
Did you mean: 

JSP : Import of com.sap.mw.jco.* is valid ?

Former Member
0 Kudos

Hi all

I want to know whther we can have

<b>

import com.sap.mw.jco.*;</b>

like this inside an JSP ???

This import brings a JAR File....

Thanks

Kay

Accepted Solutions (0)

Answers (6)

Answers (6)

former_member188321
Contributor
0 Kudos

Hi,

If you can send the proper error, or some sample code that can be anaylyzed , would be of greet help.

May be we can solve ur prob.

Former Member
0 Kudos

One of the problems might be design.

The JCO should not be involved in front end rendering i.e. jsp pages. Write your own bean to cache this part of the implementation and to handle front end needs.

Enjoy

Former Member
0 Kudos

Hi,

Check your class and package name. remember it is case-sensitive.

If your class is a bean, then use 'usebean' tag in JSP to creat a object.

Former Member
0 Kudos

Hi Kay,

can u b more specific about the error.

Regards,

Uma

Former Member
0 Kudos

Uma

I am geeting PORTAL RUN TIME ERROR

Problem in iView..

Contact System Administrator.

Since I have created a Class and made a Package, I have import the Package inside the JSP ???

Thanks

Kay

Message was edited by: Kay

Former Member
0 Kudos

Hi all

When i remove the codes added by me in the JSP, the Portal is starting up without error!!!!

Thanks

Kay

Former Member
0 Kudos

Hi,

the problem in your code is this, the myExternalTable is local to the scriplet that you have defined. so declare it first externally in your jsp. this can be done by putting the following two lines

<%@ page import= "com.sap.mw.jco.*" %>

<%!JCO.Table myExternalTable= myExt.getLogonClientList();

ZgetClientListForLogonScreen myExt = new ZgetClientListForLogonScreen();

%>

<% myExt.createConnection();

myExt.endConnect();

myExternalTable.firstRow();%>

<select name="zclientList" style="WIDTH: 20ex" size=1>

<% for (int i=0; i<myExternalTable.getNumRows(); i++)

{ %>

<option value="<%=myExternalTable.getField("MANDT").getValue()%>"><%=myExternalTable.getField("MANDT").getValue()%></option>

<%}%>

</select>

try this code.

<%! declare variables that need to be accessed across scriplets %>

regards,

P.Venkataramanan

Former Member
0 Kudos

Venkat

I have modified the code like since the JCO.Table must be declared before the Constructor

<%@ page import= "com.sap.mw.jco.*" %>

<%! <b>JCO.Table myExternalTable = null;</b>

ZgetClientListForLogonScreen myExt = new ZgetClientListForLogonScreen(); %>

.............

<% myExt.createConnection();

<b> myExternalTable= myExt.getLogonClientList();</b> myExt.endConnect();

myExternalTable.firstRow();%>

<select name="zclientList" style="WIDTH: 20ex" size=1>

<% for (int i=0; i<myExternalTable.getNumRows(); i++)

{ %>

<option value="<%=myExternalTable.getField("MANDT").getValue()%>"><%=myExternalTable.getField("MANDT").getValue();%></option>

<% } %>

</select>

But still the problem persists !!!!

Thanks

Kay

Message was edited by: Kay

Former Member
0 Kudos

Hi,

check the semicolons.

<%@ page import= "com.sap.mw.jco.*"<b>;</b> %>

<%=myExternalTable.getField("MANDT").getValue()<b>;</b>%>

regards,

P.Venkataramanan

Former Member
0 Kudos

Venkat

Still Not working

Thanks

Kay

Former Member
0 Kudos

Hi kay,

Am unable to find out the cause of error with this info. Give me your entire JSP code and bean code so that i can help. if you cant put it here mail it to me to the id "ramanan.venkat@gmail.com".

regards,

venkat

Former Member
0 Kudos

Hi Kay,

I think your code is correct. But as Venkat said, it is not advisable to include the java code like yours in JSP.

Instead of JCO.Table , you can use com.sap.mw.jco.Table if there is any ambiguity.

In case of any errors, pls let us know.

Regards,

Uma

Former Member
0 Kudos

Hi,

Yes we can do this kind of imports in JSP in scriplet or directive tag. But this is not advisable. moreover the required jar should be added to the project.

regards,

P.Venkataramanan

Former Member
0 Kudos

Hi Kay,

After adding the jar file in your project, you can import the classes in JSP as

<%@ page import="com.sap.mw.jco.*" %>

For more information, please refer the following link.

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm7.html

Regards,

Uma

Former Member
0 Kudos

Uma/Venkat

Thanks for the help...

Is this follwoing code inside the JSP is valid ??

<% ZgetClientListForLogonScreen myExt = new ZgetClientListForLogonScreen();

myExt.createConnection();

<b>JCO.Table myExternalTable= myExt.getLogonClientList();</b>

myExt.endConnect();

myExternalTable.firstRow();%>

<select name="zclientList" style="WIDTH: 20ex" size=1>

<% for (int i=0; i<myExternalTable.getNumRows(); i++)

{ %>

<option value="<%=myExternalTable.getField("MANDT").getValue()%>"><%=myExternalTable.getField("MANDT").getValue()%></option>

<%}%>

</select>

See the Bold Stmt JCO.Table should come from the imported jar !!

Is this fine ???

Please note that Class ZgetClientListForLogonScreen has already imported the said JAR ??

Is that necessary to have

<%@ page import= "com.sap.mw.jco.*" %>

agian ????

Thanks

Kay

Message was edited by: Kay

Former Member
0 Kudos

Hi kay,

why have you given JCO.Table?

if the Table class is directly under jco.* use Table alone.

JCO is the class inside jco.* and Table class is inside JCO class?

Former Member
0 Kudos

Class Documentation shows the hierarchy like this:

<b>com.sap.mw.jco.JCO.Table</b>

Is that my stmt is correct ???

Which way of coding is advisiable??? Becoz i am new to java!!!

Thanks

Kay

Former Member
0 Kudos

Hi kay,

your statement is correct. if there is any more problem let me know. try to import the required classes alone and avoid importing like jco.*. this former one is specified as best practise for java developers.

regards,

P.Venkataramanan

Former Member
0 Kudos

Hi

I am just importing com.sap.mw.jco.JCO.Table alone inside my JSP. This would be fine???

Thanks

Kay

Former Member
0 Kudos

Hi,

ya i think it should be fine. if you dont use any other class in the jco jar, this should be fine. or else you have to import that class also.

regards,

P.Venkataramanan

Former Member
0 Kudos

Hi all

I am getting a Portal Run Time Error !!!!

Thanks

Kay

Former Member
0 Kudos

Hi,

The runtime error is usually caused by some problem in your bean. so check your bean properly. your JSP may be correct.

regards,

P.Venkataramanan