代码如下:
<%@ 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>
  </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: 30 in the jsp file: /index.jsp
Generated servlet error:
conntion cannot be resolved or is not a typeAn error occurred at line: 30 in the jsp file: /index.jsp
Generated servlet error:
conntion cannot be resolved or is not a type他说出错在30行,但是30行只有“<%”
大侠们快救偶啊,急!!!!!!!!!!

解决方案 »

  1.   

    类名都写错了,conntion-->Connection
      

  2.   

    conntion conn = new conntion(); //这句有误,你是不是写错类名了??
      

  3.   

    conntion conn = new conntion();改成
    Connectionconn = new Connection();
      

  4.   

    改了之后
    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: 30 in the jsp file: /index.jsp
    Generated servlet error:
    Cannot instantiate the type Connection, since it is not a concrete classAn error occurred at line: 30 in the jsp file: /index.jsp
    Generated servlet error:
    The method getStatement() is undefined for the type Connection
      

  5.   

    conntion conn = new conntion();改成
    Connectionconn = new Connection();
    这样改后
    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 JSPAn error occurred at line: 30 in the jsp file: /index.jsp
    Generated servlet error:
    Connectionconn cannot be resolvedAn error occurred at line: 30 in the jsp file: /index.jsp
    Generated servlet error:
    Cannot instantiate the type Connection, since it is not a concrete classAn error occurred at line: 30 in the jsp file: /index.jsp
    Generated servlet error:
    conn cannot be resolvedAn error occurred at line: 38 in the jsp file: /index.jsp
    Generated servlet error:
    conn cannot be resolved
      

  6.   

    Connectionconn = new Connection();-->Connection  conn = new Connection();变量定义后要有空格
      

  7.   

    Connection conn = new Connection();这个不对,说错了,不好意思.
    应该是取得数据库连接的代码:Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                        String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Test";
                        String user="sa";
                        String password="";
                        Connection conn=DriverManager.getConnection(url,user,password);
      

  8.   

    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=phone"; 

     //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){}
    }}