Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error in JSP

 
Sridevi Kumarasamy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Java application, which I am using it as Bean in JSP page. I have jarred the necessary class files and kept it in tomcat5.0\common\classes directory.

my JSP Code is as follows:ebs.jsp

<@page language=java import=vendor>
<jsp:useBean id=bill scope=page class=Demo/>
<html>
<head><title>twain</title></head>
<body>
<form name=f1 method=post action=ebs.jsp>
<input type=submit value=scan>
<%=bill.initialise();%>
</form>
</body>
</html>

In this code, Demo is Java program, Vendor is my jar file and initialise() is a method in Demo program, which returns null value.

When I run this program in Tomcat5.0, I am getting the following errors:
Type:Exception report
The web server has encountered an internal error in fulfilling this request.
org.apache.jasper.JasperException:/evendor/ebs.jsp(2,0)The value for useBean class attribute Demo is Invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jspError("DefaultError.java")
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java)
org.apache.jasper.compiler.Generator$generatevisitor.visit(Generatot.java)
and many more exceptions.

Can anyone help me in debugging the code.

With regards

Sridevi
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sridevi Kumarasamy:
I have jarred the necessary class files and kept it in tomcat5.0\common\classes directory.


Jar files go in the lib, not the classes directory.

CATALINA_HOME/common is a place holder for classes and libraries used by both the applications and Tomcat itself. If your classes aren't being used by the Tomcat engine but need to be accessible by multiple applications, they should go under CATALINA_HOME/shared/classes or CATALINA_HOME/shared/lib (if they are jar files).

I prefer to put them under WEB-INF/classes or WEB-INF/lib. This keeps all of my code within the confines of my webapp.
 
Indraneel A Das
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sridevi, there are some mistakes in your code also which I would like to point out :

your code :
<@page language=java import=vendor>

the page directive should be like this :

1) you missed '%' in directive
2) values for attributes like language, import should be put in quotes.
This applies to all places where attribute-value pairs are present.
3) You said vendor is jar file. Jar file name are never used in import statements. Only classes and packages are used in import statements. It should be ensured that jar files is present in application classpath.

<%=bill.initialise();%>
semicolon is not necessary here

You should see to your application deployment first as Ben has suggested.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic