I have created a sample jsp file and a java class. i am calling a java class in jsp file. it is giving the error. “org.apache.jasper.JasperException: Unable to compile class for JSP: ”
below is my code.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
testClass tc = new testClass();
tc.testMethod();
%>
<h1>Hello World!</h1>
</body>
java class
public class testClass {
public void testMethod(){
System.out.println("Hello");
}
}
You have to import your java class in your JSP at the beginning. Like this-
before
<html>.Also close your
htmltag at the end. It seems unclosed.Need to mention, your class name starts a with lowercase letter. Its a good practice to give your class, a name starting with upper case letter.