I have a jsp proyect as a presentation layer to show the result (a simple string) from a function from a java class. This class is in the src directory.
When I try to run I get this errors:
org.apache.jasper.JasperException: Unable to compile class for JSP:
and then:
parser cannot be resolved to a type
My jsp code is:
<%
String input="ebnf a{non terminal A;}";
Symbol tree=null;
parser p=null;
InputStream entrada=null;
analex analizador;
try{
entrada=new ByteArrayInputStream(input.getBytes("UTF-8"));
analizador=new analex(entrada);
p=new parser(analizador);
tree=p.parse();
}catch(Exception e){
out.println("ERROR");
}
finally{}
out.println("CORRECTO");
ConDiaCClass cdc=Singleton.getInstance();
out.println(cdc);
%>
Actually I get the same problem with ConDiaCClass and analex classes too.
I have not created these class with Eclipse. They are from another project but they both are placed in the src directory (where the java classes are suposed to be). It seems that the jsp cannot recognize them.
This means that your project isn't setup to include the JUnit libraries when it compiles; JUnit is not included in the Java runtime libraries (JRE System Library) so you have to add it to the build path.
"cannot be resolved to a type" means that the compiler has decided that, according to the syntax of the language, what it found at this place in the code has to be type, which means either a class, an interface, or a primitive tpye, but cannot find the definition of any type with that name.
You should add the necessary import statements at the beginning of the jsp. A sample:
<%@ page import="java.util.List" %>
<%@ page import="yourpackage.parser, yourpackage.analex" %> //and on
An advice: make your classes follow the Java Code Conventions proposed by Oracle. It is a good guide to help other people to read easily your code (it will help yourself when you want to review/improve the code).
Clean the project,and reload the JRE as follows: Java Build Path -> Libraries -> Add Library -> JRE System Library
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With