<%@ 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
<%@ page lan...="java" pageEncoding="gb2312" %>
<%@ page import="java.lang.*, java.io.*, java.sql.*, java.util.*"%>试试吧.没用过Tomcat6.0
解决方案 »
- spring 初始化Bean出现问题
- struts2 里面的action的result中的param具体有什么用呢
- 关于springmvc+Blazads 请高人指点
- 严重: Exception sending context initialized event to listener instance of class
- hibernate条件查询的问题
- 用JAVA读写和修改XML的代码问题
- 小弟求教
- 新手请教打包bean为jar文件时产生的问题
- 200分求jboss3.2.1文档
- 我们写EJB时,只编写了Home接口和Remote接口,那么它们的实现类在哪?
- commons-logging与Log4j的问题
- 几个问题...高手来
<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>
根据提示Invalid directive呢 大致就可以确定优先出错范围
发现import等关键字没有高亮
调校后如果再有编译器提示就会出现Invalid Character于空格之上
可是有个新的问题,按书上的代码实例编写一个最简单的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 代码
不知道错在哪里,找了好久,请各位大师指点!谢谢了!