We help IT Professionals succeed at work.

can able to call function of a java class from jsp page

priyapratheep
on
515 Views
Last Modified: 2013-11-23
Hi
From my JSP page I am calling a function of a java class .I am getting error .


My jsp page where calling is
{code}barCodeClasss1 barcodeJCOObj = new barCodeClasss1();

int i =barcodeJCOObj.fetchData();{code}


My class program

{code} package mySAP;

import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO;

public class barCodeClasss1 {
public barCodeClasss1() {
createConnection();
closeConnection();
retrieveRepository();
}

private static com.sap.mw.jco.JCO.Client theConnection;
private static IRepository theRepository;

public int fetchData() {
int k = 10;
return k;

}

private static void createConnection() {
try {
theConnection = JCO.createClient("080", "yyyyy", "zzzzz", "EN",
"xxx.xxx.xx.xx", "00");
theConnection.connect();
} catch (Exception ex) {
System.out.println("Failed to connect to SAP system");
}
}

private static void closeConnection() {
try {

theConnection.disconnect();
} catch (Exception ex) {
System.out.println("Failed to connect to SAP system");
}
}

private static void retrieveRepository() {
try {
theRepository = new com.sap.mw.jco.JCO.Repository("saprep",
theConnection);
} catch (Exception ex) {
System.out.println("failed to retrieve repository");
}
}

}{code}

I am getting error

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 13 in the jsp file: /barCodeProcess.jsp
Generated servlet error:
The method fetchData() is undefined for the type barCodeClasss1


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:397)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.


--------------------------------------------------------------------------------
Help please
Regards
Comment
Watch Question

This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
yes,i recompiled
And the resulting .class file is in the WEB-INF/classes/mySAP directory?

Author

Commented:
yes it is there only...I make that to java file using JAD to check.Everything is fine.
CERTIFIED EXPERT

Commented:
restart the server and check.

Author

Commented:
can't restart..since server is production server.
You can restart the context though, right?

Author

Commented:
You can restart the context though, right?

I am not getting..
CERTIFIED EXPERT

Commented:
you do one thing. Remove the jsp compiled classes from the server and try again.
An Application is often called a Context.  You should be able to restart just your own Application on the server without affecting any other Applications.  This will reload all of your compiled classes.

Another option would be to undeploy and redeploy the context.  This will also cause it to reload your compiled classes.

Wiping the JSP cache won't affect your compiled classes though.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.