jsp连接mysql数据库404报错
代码
<pre class="html" name="code"><%@ page import ="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.mysql.jdbc.Driver" %>
<%@ page contentType="text/html; charset=GB2312" language="java" import="java.sql.*" errorPage="/WEB-INF/errorPage.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>conn.jsp</title>
</head>
<body>
<%
String server="********";
String dbname="******";
String user="******";
String pass="******";
String port="3306";
String url=="jdbc:mysql://"+server+":"+port+"/"+dbname+"?user="+user+"&password="+pass+"&useUnicode=true&characterEncoding=GB2312"
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=DriverManager.getConnection(url);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="SELECT * FROM shops_tbl;";
ResultSet rs=stmt.executeQuery(sql); //rs.first();
while(rs.next()){
out.print("用户ID:");
out.print(rs.getString("id")+" 名称:");
out.println(rs.getString("nname")+"<br>");
}
rs.close();
stmt.close();
conn.close();
错误信息
HTTP Status 404 - /connetmysql.jsp
type Status report
message /connetmysql.jsp
description The requested resource is not available.
Apache Tomcat/7.0.57
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.
-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet>
<servlet-name>TKSearch</servlet-name>
<servlet-class>TKSearch</servlet-class>
</servlet>
<servlet>
<servlet-name>TKSearchFolder</servlet-name>
<servlet-class>TKSearchFolder</servlet-class>
</servlet>
<servlet>
<servlet-name>TKSearchHeadline</servlet-name>
<servlet-class>TKSearchHeadline</servlet-class>
</servlet>
<servlet>
<servlet-name>TKSearchItem</servlet-name>
<servlet-class>TKSearchItem</servlet-class>
</servlet>
<servlet>
<servlet-name>TKSearchShop</servlet-name>
<servlet-class>TKSearchShop</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TKSearch</servlet-name>
<url-pattern>/TKSearch</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TKSearchFolder</servlet-name>
<url-pattern>/TKSearchFolder</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TKSearchHeadline</servlet-name>
<url-pattern>/TKSearchHeadline</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TKSearchItem</servlet-name>
<url-pattern>/TKSearchItem</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TKSearchShop</servlet-name>
<url-pattern>/TKSearchShop</url-pattern>
</servlet-mapping>
</web-app>
请教高手如何解决