• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jsp is not able to find classes in app-name/WEB-INF/classes/pack folder

 
manish panwar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am trying to import file present in app-name/WEB-INF/classes/pack folder in my JSP page but getting error like complier is unable to find class.

i am using tomcat6 and windows7.

import statement is working fine for util and other packages but for user package it is giving problems

can someone please help me.

here is the class
---------------------------------------------------

package pack;

public class dog
{
String name;

public void setName(String name)
{
this.name=name;
}

public String getName()
{
return name;
}
}

and the JSP code is
--------------------------------------------------------

<%@ page import="pack.*" %>
<html>

<body>
here we are setting the attributes
<%
dog do= new dog();
%>
<a href="att2.jsp"> click here to go to second page </a>
<body>

</html>

error i am getting is
-------------------------------------------------------------------------------------------------

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

An error occurred at line: 7 in the jsp file: /att1.jsp
dog cannot be resolved
4: <body>
5: here we are setting the attributes
6: <%
7: dog do= new dog();
8: %>
9: <a href="att2.jsp"> click here to go to second page </a>
10: <body>


An error occurred at line: 7 in the jsp file: /att1.jsp
Syntax error on token "do", delete this token
4: <body>
5: here we are setting the attributes
6: <%
7: dog do= new dog();
8: %>
9: <a href="att2.jsp"> click here to go to second page </a>
10: <body>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do is a reserved keyword in Java programming language.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be putting Java code in a JSP. That's a poor practice that has been discredited for almost 10 years now. Use JSTL and EL.
 
tyte kyat
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you already compiled your " .java" file?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!