1、实验一:xingyan.html输入您的姓名:选择性别:男女选择你喜欢的球队:国际米兰队AC 米兰队罗马队中国队package cn.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;publ
2、ic class xingyan extends HttpServlet /* Constructor of the object.*/public xingyan() super();/* Destruction of the servlet. */public void destroy() super.destroy(); / Just puts “destroy“ string in log/ Put your code here/* The doPost method of the servlet. * This method is called when a form has its
3、 tag value method equals to post.* * 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 doPost(HttpServletRequest request, HttpSer
4、vletResponse response)throws ServletException, IOException response.setContentType(“text/html;charset=GB2312“);request.setCharacterEncoding(“GB2312“);PrintWriter out=response.getWriter();String a=request.getParameter(“username“);out.print(“输入你的姓名:“+a);String b=request.getParameter(“man“);out.print(“
5、选择性别:“+b);Stringc=request.getParameterValues(“ch“);out.print(“选择我喜欢的球队:“);for(int i=0;i* throws ServletException if an error occurs*/public void init() throws ServletException / Put your code here“My JSP counter.jsp starting page当前访问次数:实验二:“My JSP example.jsp starting page输入您的姓名:选择性别:男女选择你喜欢的球队:国际米兰
6、队AC 米兰队罗马队中国队“My JSP example_session.jsp starting page实验三:先建一个 classpackage com.javabean;public class liuyanban public liuyanban()public String getNnn()return nnn;public void setNnn(String nnn)this.nnn=nnn;public String getMmm()return mmm;public void setMmm(String mmm)this.mmm=mmm;public String getR
7、rr()return rrr;public void setRrr(String rrr)this.rrr=rrr;private String nnn;private String mmm;private String rrr;“My JSP liuyan.jsp starting page留言者:留言标题:留言内容:“My JSP liuyanban.jsp starting page留言者:留言标题:留言内容:实验六:“My JSP aihao.jsp starting page姓名:密码:性别:男女年龄:10-2020-3030-4040-50兴趣:看书玩游戏旅游听音乐看电视“My J
8、SP biaoxian.jsp starting page$“姓名:“$param.ccc$“密码:“$param.aaa$“性别:“$param.man$“年龄:“$param.old$“兴趣:“$paramValues.ch0$paramValues.ch1$paramValues.ch2$paramValues.ch3$paramValues.ch4实验七:“My JSP xy.jsp starting pageabcdefghijklmnopqrst$result1.01.2wangtouppercasecom.bb.xyvartrue实验八:“My JSP aaa.jsp starting page号码数字平方$b.count$a$a*a