代码://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>
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>
解决方案 »
- jsp中select标签传值的奇特问题,虽然我已经解决,但是还是说下和大家探讨
- 求Linux版的tomcat5.0和jdk1.4下载地址
- 关于地址栏中输入中文,得到乱码的原理问题,请大家指教。
- Collections.sort 排序问题
- 在JSP中如何实现页面重定向功能?
- 现在我该学什么
- 想获得项目的根目录路径
- 用JSP做一个下棋的网站,想问下钱的问题
- 为什么设置了filter不起作用。在线
- 使用JBuilder6出现的“找不到数据库驱动”的问题
- 不能重定向是什么原因?
- 哪位高手能解释得清楚这条语句是如何工作的:new String(str.getBytes("8859-1"),"gb2312")
<?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>是不是写的不对?