[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 413
  • Last Modified:

JSP Compile error in Tomcat.. MASSIVE POINTS!!!

Hi, I have the following 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: -1 in the jsp file: null

Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sunny\customer_jsp.java:7: package classes does not exist
    [javac] import classes.UserData;
    [javac]                ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sunny\customer_jsp.java:43: cannot find symbol
    [javac] symbol  : class UserData
    [javac] location: class org.apache.jsp.customer_jsp
    [javac]       UserData ud = null;
    [javac]       ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sunny\customer_jsp.java:45: cannot find symbol
    [javac] symbol  : class UserData
    [javac] location: class org.apache.jsp.customer_jsp
    [javac]         ud = (UserData) pageContext.getAttribute("ud", PageContext.APPLICATION_SCOPE);
    [javac]               ^
    [javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\sunny\customer_jsp.java:48: cannot find symbol
    [javac] symbol  : class UserData
    [javac] location: class org.apache.jsp.customer_jsp
    [javac]             ud = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
    [javac]                   ^
    [javac] 4 errors

      at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
      at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
      at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
      at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:595)
==========================================================================================================================
HTML FILE - Q4!!
<html>
<head> <title>Provide Info</title>

<script language= "JavaScript">



function correctEmail(){
re = /@/
if(re.test(document.question4.email.value))

window.location="http://localhost:8080/sunny/customer.jsp"
else{
   alert("Invalid email address")
   document.question4.email.focus()
}
}




</script>
</head>

<body>

<form name = "question4" action ="http://localhost:8080/sunny/customer.jsp">
<input type="text" name="user"> What is your name? <P>
<input type="text" name="email"> What is your email address?<P>
<input type="text" name="age"> What is your age? <P>
<input type="button" value="Submit Query" onClick="correctEmail()">
</body>
</html>
==========================================================================================================================
JSP FILE - CUSTOMER!!!
<%@ page import='classes.UserData' %>
<jsp:useBean id="ud" class="UserData" scope="application"/>
<jsp:setProperty name="ud" property="*"/>

<html>
<head><title>Customer Info </title></head>

<body>
User name is <%= ud.getUser()%>
<P>
Email address is <%= ud.getEmail()%>
<P>
Age is <%=ud.getAge()%>

</body>
</html>
==========================================================================================================================
UserData JAVA FILE!!!!
public class UserData{
      
      String user;
      String email;
      int age;
      
      public void setUser(String u){
            
            user = u;
      }
      
      public String getUser(){
            return user;
      }
      
      public void setEmail(String e){
            email = e;
      }
      
      public String getEmail(){
            return email;
      }
      
      public void setAge(int a){
            age = a;
      }
      
      public int getAge(){
            return age;
      }
      
      public String toString(){
            
            String x = getEmail();
            String y = getUser();
            int z =  getAge();
            
            String meaningful = x + "," +y+","+z;
            return meaningful;
      }
}
==========================================================================================================================
Please post any questions..

Thanks!! :D
0
deepanp
Asked:
deepanp
4 Solutions
 
hoomanvCommented:
http://jakarta.apache-korea.org/tomcat/faq/misc.html
the first answer in the page is what you want
0
 
hoomanvCommented:
0
 
rrzCommented:
I think you need to make some changes to your code.  
>UserData JAVA FILE!!!!
>public class UserData{
add this first line to declare your package in UserData.
package classes  
public class UserData{  
In your JSP
><%@ page import='classes.UserData' %>
><jsp:useBean id="ud" class="UserData" scope="application"/>
Remove the page directive and change the second line to  
<jsp:useBean id="ud" class="classes.UserData" scope="application"/>

Please put your class file here.  
C:\Program Files\Apache Group\Tomcat 4.1\webapps\sunny\WEB-INF\classes\classes\UserData.class    
Ok, now try it.    rrz




0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
>>classes.UserData

Is UserData.class directly there in the classes folder or is it inside another folder called classes inside classes.?

If it is directly there in classes folder then you just need to import
<%@ page import='UserData' %>

I think the UserData class is in the direct classes folder just check it out.

As such the excption here is because of the JSP is not able to find your Bean class.
0
 
rrzCommented:
shivaspk, good point. I was assuming that  deepanp was using a package called classes(a poor choice for a name because of the confusion). But maybe he wasn't using any package at all.  

So, please comment and  we  will be able to help you.  JSPs  require that javabeans use packages.  See links already posted in your other question.   rrz
0
 
Mayank SAssociate Director - Product EngineeringCommented:
My guess is that its not packaged. It says package classes does not exist, means no such package is created in the first place (whether or not the class is defined in it).
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now