web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"  
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">
  <servlet>
  <description>This is the description of my J2EE component</description>
  <display-name>This is the display name of my J2EE component</display-name>
  <servlet-name>testServlet2</servlet-name>
  <servlet-class>servlet.testServlet2</servlet-class>
  </servlet>  <servlet-mapping>
  <servlet-name>testServlet2</servlet-name>
  <url-pattern>/test</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
   
</web-app>
jsp:
<%@ page language="java" import="java.util.*,common.DBConnection" pageEncoding="gbk"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><html>
  <head>
  </head>
   
  <body>
  <a href="test">do</a>
  </body>
</html>
servlet包下的testServlet2:
package servlet;import java.io.IOException;
import java.io.PrintWriter;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;public class testServlet2 extends HttpServlet {/**
* Constructor of the object.
*/
public testServlet2() {
super();
}/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*  
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}}
报错:
type Status reportmessage /ownHome_Version_0107_00/testdescription The requested resource (/ownHome_Version_0107_00/test) is not available.

解决方案 »

  1.   

    报错:
    type Status reportmessage Servlet testServlet is not availabledescription The requested resource (Servlet testServlet is not available) is not available.
      

  2.   

    你看看编译和部署是否有问题,去web服务器项目里看看是否成功部署进去了,class是否编译好了
      

  3.   

    现在倒是调转进去了,但是不论怎么改动servlet里面的内容,总是这一句This is class servlet.testServlet, using the GET method 
      

  4.   

    我重启了一下tomcat服务器好像可以了。
    现在是这个问题:
        public DBConnection(){
         Context initContext;
    try {
    initContext = new InitialContext();     Context envContext = (Context)initContext.lookup("java:/comp/env");
         
         DataSource ds = (DataSource)envContext.lookup("jdbc/ownHome");       dbConn = ds.getConnection(); 
        Statement   stmt   =   dbConn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY) ;   
    String sql="select * from USERS";  
    rs= stmt.executeQuery(sql);  
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
        }
    最后取到的rs为什么是null啊
      

  5.   

    DEBUG 是解决这种问题 最快速的途径