<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
 <% for(int i=0;i<10;++i)
{
out.print(i);
}
 %> </body>
</html>这个可以运行 在Tomcat 下可以。但是 下面就不可以了。<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%><%@ page import = "java.sql.*" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
 <%
   Date date = new Date();
   out.print(d);
 %> 
</body>
</html>
为什么呢。
org.apache.jasper.JasperException: Unable to compile class for JSP: 
为什么提示没有编译呢??

解决方案 »

  1.   


    <% 
      Date date = new Date(); 
      out.print(d); 
    %>d是哪里来的,LZ看仔细了。
      

  2.   

    代码 我打错了。。

    Date date = new Date();
    out.print(date)
    的 。。我导入了
    <@ page import = "java.util.*" %>
    就可以了。。
      

  3.   

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
        pageEncoding="ISO-8859-1"%> <%@ page import = "java.sql.*" %> //好像你没有用到数据库方面的吧<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
    <title>Insert title here </title> 
    </head> 
    <body> 
    <% 
      Date date = new Date(); //没有写完整Date()的引用包
      out.print(d); //这里应该是date吧?
    %> 
    </body> 
    </html> 
    解决方法:
    方法一:将<%@ page import = "java.sql.*" %>修改为:<%@ page import = "java.util.*" %>,后面不用修改.
    方法二:将Date date = new Date(); 修改为:java.util.Date date = new java.util.Date();
      

  4.   

     不行的程序,  
    <% 
      Date date = new Date(); 
      out.print(d); 
    %> 
    基础问题啦!好好再看看
      

  5.   

    org.apache.jasper.JasperException: Unable to compile class for JSP 解决方法:
    1,检查是否将classpath设置错误:正确的为.;%java_home%\lib\rt.jar;%java_home%\lib\tools.jar  <!--java_home is your jdk directory-->
    2,This   can   usually   be   solved   by   copying   manually   $JAVA_HOME/lib/tools.jar   from   the   JDK     
      to   the   common/lib   directory   of   the   Tomcat   server,   followed   by   a   Tomcat   restart.       
      看到了吗?   
      把jdk安装目录下的lib/tools.jar拷贝到tomcat安装目录下的common/lib目录下,然后重启tomcat,试试   。
      

  6.   

    org.apache.jasper.JasperException: Unable to compile class for JSP 解决方法
    1,检查是否将classpath设置错误:正确的为.;%java_home%\lib\rt.jar;%java_home%\lib\tools.jar  <!--java_home is your jdk directory-->
    2,This   can   usually   be   solved   by   copying   manually   $JAVA_HOME/lib/tools.jar   from   the   JDK     
      to   the   common/lib   directory   of   the   Tomcat   server,   followed   by   a   Tomcat   restart.       
      看到了吗?   
      把jdk安装目录下的lib/tools.jar拷贝到tomcat安装目录下的common/lib目录下,然后重启tomcat,试试   。