代码如下:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ page import="conn.*"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  </head>
  
  <body>
<IMG src="IMAGE/a.bmp" border="0">
<TABLE border="1" width="100%">
<TR>
<%
 conntion conn = new conntion();
 Statement st = conn.getStatement();
 String sql="select * from MENU order by MenuId";
 ResultSet rs=st.executeQuery(sql);
         while(rs.next()){
%>
<TD height="23" width="110" align="center"><a href="<%=rs.getString("MenuUrl")%>" target="<%=rs.getString("MenuOpentype")%>"><%=rs.getString("MenuName")%></a></TD>
<%
}
        conn.close(); 
%>
</TR>
</TABLE>
<P></P></body>
</html>
报错:
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 JSPAn error occurred at line: 31 in the jsp file: /index.jsp
Generated servlet error:
conntion cannot be resolved or is not a typeAn error occurred at line: 31 in the jsp file: /index.jsp
Generated servlet error:
conntion cannot be resolved or is not a type

解决方案 »

  1.   

    conntion conn = new conntion(); 拼写错误?
     connection conn = new connection();
      

  2.   

    package conn;import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;public class conntion { /**
     * @param args
     */
    Connection con = null;
    Statement st = null;
    /*public String getString() {
    // TODO Auto-generated method stub
    System.out.println("321");
    String ABC ="user";

    return ABC; }*/
    public Statement getStatement() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{

     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
          
     String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=books"; 

     //pubs为你的数据库的 

     String user="sa"; 

     String password="sa"; 
     
     con= DriverManager.getConnection(url,user,password); 
     
     st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
     //System.out.println("数据库连接成功!!!KFC");
     
    return st; 

    }

    public void close(){

    try{
    if(st!=null ){
    st.close();
    }
    if(con!=null){
    con.close();
    }
    }
    catch(Exception e){}
    }}
      

  3.   

    package conn;import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;public class conntion { /**
     * @param args
     */
    Connection con = null;
    Statement st = null;
    /*public String getString() {
    // TODO Auto-generated method stub
    System.out.println("321");
    String ABC ="user";

    return ABC; }*/
    public Statement getStatement() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException{

     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); 
          
     String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=books"; 

     //pubs为你的数据库的 

     String user="sa"; 

     String password="sa"; 
     
     con= DriverManager.getConnection(url,user,password); 
     
     st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
     //System.out.println("数据库连接成功!!!KFC");
     
    return st; 

    }

    public void close(){

    try{
    if(st!=null ){
    st.close();
    }
    if(con!=null){
    con.close();
    }
    }
    catch(Exception e){}
    }}
    代码如下:
    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <%@ page import="conn.*"%>
    <%@ page import="java.sql.*"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
        
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page">
        
        <!--
        <link rel="stylesheet" type="text/css" href="styles.css">
        -->
      </head>
      
      <body>
    <IMG src="IMAGE/a.bmp" border="0">
    <TABLE border="1" width="100%">
    <TR>
    <%
     conntion conn = new conntion();
     Statement st = conn.getStatement();
     String sql="select * from MENU order by MenuId";
     ResultSet rs=st.executeQuery(sql);
             while(rs.next()){
    %>
    <TD height="23" width="110" align="center"><a href="<%=rs.getString("MenuUrl")%>" target="<%=rs.getString("MenuOpentype")%>"><%=rs.getString("MenuName")%></a></TD>
    <%
    }
            conn.close(); 
    %>
    </TR>
    </TABLE>
    <P></P></body>
    </html>
    报错:
    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 JSPAn error occurred at line: 31 in the jsp file: /index.jsp
    Generated servlet error:
    conntion cannot be resolved or is not a typeAn error occurred at line: 31 in the jsp file: /index.jsp
    Generated servlet error:
    conntion cannot be resolved or is not a type
      

  4.   

    conntion conn = new conntion(); 拼写错误?