代码://GetInfo.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */public class GetInfo extends HttpServlet {
  public GetInfo() {
  }  public void doGet(HttpServletRequest request,HttpServletResponse response)
      throws ServletException,IOException{
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body bgcolor=\"white\">");
    out.println("<head>");
    String title = "读取表单数据";
    String body = request.getParameter("username");
    out.println("<title>"+ title + "</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>" + title + "</h1>");
    out.println("<p>" + body + "</p>");
    out.println("</body>");
    out.println("</html>");
  }}
//getInfo.htm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head><body>
<form method="get" action="http://localhost:8080/servlet/GetInfo">
<p>input name</p>
<p><input type="text" name="username"></p>
<p>
<input type="submit" name="submit1" value="提交">
<input type="reset" name="submit2" value="重置">
</p>
</form>
</body>
</html>

解决方案 »

  1.   

    把getInfo.htm和GetInfo.class代码贴出来,为什么会是getInfo.htm,而不是getInfo.jsp???
      

  2.   

    不应该是把GetInfo.class放在...\JBuilder9\project\TryJSP\defaultroot\WEB-INF\servlet下应该是:把GetInfo.class放在...\JBuilder9\project\TryJSP\defaultroot\WEB-INF\classes下!
      

  3.   

    代码应该没错可能是web.xml的问题看看web.xml是怎么写的,然后按照那个地址在地址栏上填写,然后浏览
      

  4.   

    文件命名为getInfo.htm或者是getInfo.jsp,有什么不一样吗?我已经更改为getInfo.jsp,还是不好用期待中...
      

  5.   

    我的web.xml代码如下:
    <?xml version="1.0" encoding="UTF-8"?>
    <!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>
      <servlet>
        <servlet-name>debugjsp</servlet-name>
        <description>Added to compile JSPs with debug info</description>
        <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
        <init-param>
          <param-name>classdebuginfo</param-name>
          <param-value>true</param-value>
        </init-param>
        <load-on-startup>3</load-on-startup>
      </servlet>
      <servlet-mapping>
        <servlet-name>debugjsp</servlet-name>
        <url-pattern>*.jsp</url-pattern>
      </servlet-mapping>
        <servlet>
            <servlet-name>GetInfo</servlet-name>
            <servlet-class>GetInfo</servlet-class>
        </servlet>
    </web-app>是不是写的不对?
      

  6.   

    GetInfo没有servlet映射<servlet-mapping>