Hi,
I tried to run a simple JSP example and get an error while accessing a JSP.
Under the webapps directory of my Tomcat 4.1.10 installation I created a directory 
named "Tracking". Under that directory I have a driectory named "jsp". Under that 
directory I have another directy named "tracking" in which I stored two JSP files 
"logInForm.jsp" and "test.jsp". The "logInForm.jsp" is a simple formular in which the 
user can enter a user-name, a password and other parameter needed for an login in my 
backend system. When the user submits this form the request is directed to the URL 
http://localhost:8080/Tracking/jsp/tracking/test.jsp At this point Tomcat tries to 
compile the "test.jsp" into a servlet. The "test.jsp" should create a new instance of 
a Java class named "tracking.testBean" in which all the login data the user has 
entered in the formular will be stored. The "test.jsp" is quite easy:
    <%@ page errorPage="ErrorPage.jsp" %>
    <%@ page import = "tracking.TestBean" %>

    <jsp:useBean id="testBean" class="tracking.TestBean" scope="session">
    </jsp:useBean>
    <jsp:setProperty name="testBean" property="*" />

    <%
     java.io.FileWriter file=new java.io.FileWriter("g:\\tracking\\output.log", true);
   
     //DEBUG
       file.write("test.jsp:TestBean:\n");
       file.write("\t sessionID: "+ session.getId() +"\n");
       file.write("\t user: "+testBean.getUser()+"\n");
       file.write("\t password: "+testBean.getPassword()+"\n");
       file.write("\t server: "+testBean.getServer()+"\n");
      file.close();
    //DEBUG ENDE
  %>

 
While compiling the "test.jsp" the following error occured:

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

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
        [javac] Compiling 1 source file
    
F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:7:
 cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
    import tracking.TestBean;
                    ^
    
F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:44:
 cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
          tracking.TestBean testBean = null;
                  ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
    
F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:46:
 cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
            testBean = (tracking.TestBean) pageContext.getAttribute("testBean", 
PageContext.SESSION_SCOPE);
                                ^

    An error occurred at line: 4 in the jsp file: /jsp/tracking/test.jsp

    Generated servlet error:
    
F:\Programme\Apache\Tomcat_4.1.10\work\Standalone\localhost\Tracking\jsp\tracking\test_jsp.java:49:
 cannot resolve symbol
    symbol  : class TestBean  
    location: package tracking
                testBean = (tracking.TestBean) 
java.beans.Beans.instantiate(this.getClass().getClassLoader(), "tracking.TestBean");
                                    ^
    4 errors

    at 
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:120)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:315)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:326)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182)


I've no idea why Tomcat is'nt able to find the Java class "tracking.TestBean". I've 
stored the file "TestBean.class" in the directory 
"...webapps\Tracking\Web-Inf\classes\tracking".

Thank you for your hints!

Bye
Sven Hoffmann.

Reply via email to