<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %> 把里边的分开写一下吧
<%@ page lan...="java" pageEncoding="gb2312" %>
<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*"%>试试吧.没用过Tomcat6.0

解决方案 »

  1.   

    原因很简单,你的语句中使用的是中文的全角空格,把它们替换一下就可以了!另外Class.forName 哪一行少了一个分号<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*" contentType="text/html;charset=gb2312" %> 
       <html> 
       <body> 
       <% Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");//.newInstance(); 
       String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs"; 
       //pubs 为你的数据库的 
       String user="sa"; 
       String password=""; 
       Connection conn= DriverManager.getConnection(url,user,password); 
       Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); 
       String sql="select job_id,job_desc from jobs"; 
       ResultSet rs=stmt.executeQuery(sql); 
       while(rs.next()) { %> 
        您的第一个字段内容为: <%=rs.getString(1)%> <br> 
        您的第二个字段内容为: <%=rs.getString(2)%> <br> 
       <% } %> 
       <% out.print("数据库操作成功,恭喜你"); %> 
       <% rs.close(); 
       stmt.close(); 
       conn.close(); 
      %> 
       </body> 
       </html>  
      

  2.   

    老紫竹挺仔细的
    根据提示Invalid directive呢  大致就可以确定优先出错范围
    发现import等关键字没有高亮
    调校后如果再有编译器提示就会出现Invalid Character于空格之上
      

  3.   

    谢谢java2000_net及各位热心朋友.已经搞定.
    可是有个新的问题,按书上的代码实例编写一个最简单的Servlet,其功能是向客户端输出一个字符串"Hello world"
    事例开发有如下几个步骤:STEP1:编写SimpleHello.java文件,文件的保存目录为%CATALINA_HOME%\webapps\ch06\src    文件如下,import javax.servlet.ServletException;
    import java.io.*;
    import javax.servlet.http.*;public class SimpleHello extends HttpServlet
    {
     public void doGet(HttpServletRequest req,HttpServletResponse resp)throws ServletException,IOException
     {
      PrintWriter out=resp.getWriter();
      out.println("hello world");
      out.close();
      }
      }
    step2:编译SimpleHello.java  成功step3:部署Servlet
    按它的说法我把编译后的SimpleHello.class 文件COPY到 \ch06\WEB-INF\classes  目录下
    接下来在 \ch06\WEB-INF\ 下部署web.xml  文件如下<?xml version="1.0" encoding="ISO-8859-1"?>
    <!--
     Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at      http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    --><web-app xmlns="http://java.sun.com/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
       version="2.5">  <display-name>Welcome to Tomcat</display-name>
      <description>
         Welcome to Tomcat
      </description>
      
      <!-- JSPC servlet mappings start -->
      
      <servlet>
             <servlet-name>helloworld</servlet-name>
             <servlet-class>SimpleHello</servlet-class>
      </servlet>
      
      <servlet-mapping>
        <servlet-name>helloworld</servlet-name>
        <url-pattern>hello</url-pattern>
      </servlet-mapping>
    </web-app>
      
    step4:访问SimpleHello 打开http://localhost:8080/ch06/hello
    显示为HTTP Status404 代码
     不知道错在哪里,找了好久,请各位大师指点!谢谢了!
     
      

  4.   

    文件找不到错误~~改成<url-pattern>/hello </url-pattern>这样试试~~
      

  5.   

    如果我没记错,你的项目启动的时候就会报错.url-patten里边的内容应该是以/开头