<%@ page contentType="text/html;charset=GB2312" %><HTML>
<BODY>
   
<%
  a a1=new a();
%>
   
    <P>您是第
       <%=a1.i%>
       个访问本站的客户。
</BODY>
</HTML>本目录下包ad内的java文件是public class  a{
   int i=7;
   public static void main(String[] args){
   a a1=new a();
   System.out.println(a1.i);   }}
jsp运行后出现下面的问题
type Exception reportmessage 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: 7 in the jsp file: /1.jsp
a cannot be resolved to a type
4: <BODY>
5:    
6: <%
7:   a a1=new a();
8: %>
9:    
10:     <P>您是第
An error occurred at line: 7 in the jsp file: /1.jsp
a cannot be resolved to a type
4: <BODY>
5:    
6: <%
7:   a a1=new a();
8: %>
9:    
10:     <P>您是第
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.

解决方案 »

  1.   

    <%@ page contentType="text/html;charset=GB2312" import="java.util.*,你的a类的全类名"%> 
      

  2.   

    忘了说句,加了之后还是出现一样的问题
    <%@ page contentType="text/html;charset=GB2312" %> 
    <%@ page import = "ad.*" %>
    <%@ page import = "java.util.*" %>
    <HTML>
    <BODY>
       
    <%
      a a1=new a();
    %>
       
        <P>您是第
           <%=a1.i%>
           个访问本站的客户。
    </BODY>
    </HTML>
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage 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: 7 in the jsp file: /1.jsp
    a cannot be resolved to a type
    4: <BODY>
    5:    
    6: <%
    7:   a a1=new a();
    8: %>
    9:    
    10:     <P>您是第
    An error occurred at line: 7 in the jsp file: /1.jsp
    a cannot be resolved to a type
    4: <BODY>
    5:    
    6: <%
    7:   a a1=new a();
    8: %>
    9:    
    10:     <P>您是第
    Stacktrace:
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:85)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:415)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:308)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.10 logs.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.10
      

  3.   

    本目录下包ad内的java文件是 明确的说,我看不懂你的意思。哈哈哈!
    啥叫本目录?
    啥叫包ad?
    怎么还有java文件。系统运行需要的是class文件。
      

  4.   


    <%@ page language="java" import="java.util.*,com.eassen.A"
    pageEncoding="gb2312"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    test
    </head> <body>
    <%
    A a1 = new A();
    %> <P>
    您是第
    <%=a1.getCount()%>
    个访问本站的客户。
    </body>
    </html>=================
    package com.eassen;public class A { int count=0; /**
     * @return the count
     */
    public int getCount() {
    return count;
    } /**
     * @param count the count to set
     */
    public void setCount(int count) {
    this.count = count;
    }
    }
      

  5.   

    你的程序很多问题,首先你写的那个java文件打印的内容只会出现在控制台,不会出现在jsp。导入类的时候其实很简单
      <%@ page import="java.util.*,你的a类的全类名"%> 
      

  6.   

    我是楼主
    楼上的
    我去掉a类的main方法后还是出项一样的问题
      

  7.   

    我是楼主 
    是不是要把编译好的class文件放入WEB-INF文件夹内的classes文件夹内
    我把a.class放入WEB-INF文件夹内的classes文件夹内还是出现一样的问题