这个可能行就多了,你在命令行执行时不需要在类里写上package,但是在jsp中如果是在某个暴力就必须鞋,把你的代码贴出来,写上你的类路径,大家分析看看

解决方案 »

  1.   

    以下是源代码,请大家帮我分析看看,首先说明一下,服务器配置正常,可运行其他 HTML,JSP,SERVLET.但以前使用时未导入包.环境 : WIN2000 SERVER + JDK 1.4 + Apache 2.0.45 + Tomcat 5.0 + MySQL 3.23.55 .    类路径设置 classpath e:\website\jsp\;.......
        目录结构 e:\website\jsp\bean;
    DBControlBean.javapackage bean;import bean.dbconn.DBConnection;
    import java.sql.*;public class DBControlBean
    {
        DBConnection dbc = null;
        ResultSet rset = null;
        
        public DBControlBean()
        {
            dbc = new DBConnection();
        }
        
        public boolean openConnection()
        {
            return dbc.openConnection();
        }
        
        public void executeQuery(String query) throws SQLException
        {
            this.rset = dbc.executeQuery(query);
        }    
        
        public void executeUpdate(String query) throws SQLException
        {
            dbc.executeUpdate(query);
        }
        
        public int getColumnCount() throws SQLException
        {
            ResultSetMetaData rsmd = rset.getMetaData();
            return rsmd.getColumnCount();
        }
        
        public String getColumnName(int index) throws SQLException
        {
            ResultSetMetaData rsmd = rset.getMetaData();
            return rsmd.getColumnName(index);
        }
        
        public String getString(int index) throws SQLException
        {
            return rset.getString(index).trim();
        }
        
        public String getString(String columnName) throws SQLException
        {
            return rset.getString(columnName).trim();
        }
        
        public boolean next() throws SQLException
        {
            return rset.next();
        }
        
        public void close() throws SQLException
        {
            if(rset != null) rset.close();
            if(dbc != null) dbc.close();
        }
        
        protected void finalize() throws Throwable
        {
            close();
        }
    }
        register.jsp<%@page language="java" import="bean.DBControlBean" contentType="text/html;charset=GB2312" info="Register User to DataBase" %><jsp:useBean id="regBean" scope="request" class="DBControlBean" /><%  String username = request.getParameter("username");
      String password = request.getParameter("password");
      String sex = request.getParameter("sex");
      String age = request.getParameter("age");
      String phone = request.getParamter("phone");
      String portrait = request.getParameter("portrait");
      String mail = request.getParameter("mail");
      String sign = request.getParameter("sign");
      String oicq = request.getParameter("oicq");
      String look = request.getParameter("look");  regBean.executeUpdate("insert into user values (username,password,sex,age,phone,portrait,mail,sign,oicq,look)");
      
     
    %><html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>用户注册</title>
    </head>
    </html>
      

  2.   

    类路径是放在你自己建的目录中的。如:你的文件夹是myweb。它里面建两个文件夹jsp和Web-inf,在jsp文件夹中放你的jsp文件。Web-inf它里面建个classes文件夹。和一个web.xml文件。classes文件夹放你的类文件。web.xml文件的内容和root目录下的web.xml文件内容一样。