丝路之行zhengdong.blog.chinaunix.net
zhengdong1987
全部博文(101)
MySQL(2)
AVR(0)
Android_APP(7)
SNMP(15)
Servlet(7)
html(1)
Jsp(1)
WEB(0)
Java编程(15)
MVC(0)
Eclipse(0)
Spring(0)
Tomcat(1)
应用(29)
qt(0)
Linux驱动(6)
2012年(3)
2011年(60)
2010年(38)
ayyicdms
曾德标
zwsolive
shuixing
zhangjie
jchaodon
tekkaman
大鬼不动
sswqzx
浪花小雨
Bsolar
wenfei63
dahai071
HuangWJ_
mxj30708
zxcvbnm4
alex1028
zjc06181
分类: 系统运维
2010-11-21 20:01:25
package shark.zd.servlets;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.Servlet;import javax.servlet.ServletConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;public class WlecomeServlet implements Servlet { /* * 撤销前需要做的事情 */ public void destroy() { // TODO Auto-generated method stub } //获得配置信息 public ServletConfig getServletConfig() { // TODO Auto-generated method stub return null; } public String getServletInfo() { // TODO Auto-generated method stub return null; } //初始化 public void init(ServletConfig arg0) throws ServletException { // TODO Auto-generated method stub } //在Servlet中做的事情在这里去做 public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { System.out.println("welcome被执行了"); PrintWriter out = response.getWriter(); request.getParameter("username"); String radio = request.getParameter("testRadio"); out.print(radio+""); out.print(request.getParameter("sw")+""); String[] c = request.getParameterValues("c1"); for(String str:c){ out.print(str+""); } out.flush(); }}
HTML代码为:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>test.html</title> </head> <body> <form action="wlecome"> 请输入你的名字:<input type="text" name="username" /></br> <input type="radio" name="testRadio" value="man">男</br> <input type="radio" name="testRadio" value="woman">女</br> <select name="sw"> <option value="s">s</option> <option value="w">w</option> </select> <input type="checkbox" name="c1" value="c1"> <input type="checkbox" name="c2" value="c2"> <input type="checkbox" name="c3" value="c3"> <input type="checkbox" name="c4" value="c4"> <input type="submit" value="提交" /> </form> </body></html>
上一篇:BS and CS
下一篇:servlet中request与response的简单用法
chinaunix网友2010-11-22 17:24:17
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com
登录 注册