besides copy/move ur servlet class file in WEB-INF/classes directory, u should also config web.xml file to map ur servlet class to URI path. web.xml is under WEB-INF/

解决方案 »

  1.   

    Thanks,But why the browser cannot find the Servlet if its class name was changed one times (and I changed the name back to its old name)?And how to map servlet class to URI path. My web.xml file is as following.--------------------------------------------- web.xml
    <?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE web-app
        PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
        "http://java.sun.com/j2ee/dtds/web-app_2.2.dtd"><web-app>
        <servlet>
            <servlet-name>Simple</servlet-name>
            <servlet-class>ewebjava.Simple</servlet-class>
            <init-param>
               <param-name>
                SimpleParam
               </param-name>
               <param-value>
                This is the simple parameter
               </param-value>
            </init-param>
        </servlet>    <servlet>
            <servlet-name>Index</servlet-name>
            <servlet-class>index</servlet-class>
            <init-param>
               <param-name>
                AParam
               </param-name>
               <param-value>
                This is the Index parameter
               </param-value>
            </init-param>
        </servlet>    <servlet>
            <servlet-name>JSPIndex</servlet-name>
            <jsp-file>/index.jsp</jsp-file>
            <init-param>
               <param-name>
                AParam
               </param-name>
               <param-value>
                This is the .idx parameter
               </param-value>
            </init-param>
        </servlet>    <servlet-mapping>
            <servlet-name>Simple</servlet-name>
            <url-pattern>/Simple</url-pattern>
        </servlet-mapping>    <servlet-mapping>
            <servlet-name>Simple</servlet-name>
            <url-pattern>*.sml</url-pattern>
        </servlet-mapping>    <servlet-mapping>
            <servlet-name>Index</servlet-name>
            <url-pattern>*.idx</url-pattern>
        </servlet-mapping>    <servlet-mapping>
            <servlet-name>Index</servlet-name>
            <url-pattern>/Index</url-pattern>
        </servlet-mapping>    <servlet-mapping>
            <servlet-name>JSPIndex</servlet-name>
            <url-pattern>/JSPIndex</url-pattern>
        </servlet-mapping>    <welcome-file-list>
            <welcome-file>Simple.html</welcome-file>
        </welcome-file-list></web-app>