仅供参考!!!!!1.人员简历htmlheadmetacharset=UTF-8title人员简历/title/headbodyformmethod=posttabletrtd姓名:/tdtdinputtype=textname=name/td/trtrtd电话:/tdtdinputtype=textname=phone/td/trtrtd性别:/tdtdinputtype=radioname=sex男inputtype=radioname=sex女/td/trtrtd个人介绍/tdtdtextareacols=70rows=10/textarea/td/trtrtdcolspan=3align=centerinputtype=submitname=保存按钮value=保存/td/tr/table/form/body/html结果截图2.登录页面方法一:htmlheadtitle登录页面/titlescriptlanguage=JavaScriptfunctioncheck(){vars1=document.myForm.uname.valueif(s1.length==0){alert(姓名不能为空)returnfalse}vars2=document.myForm.pwd.valueif(s2.length12||s2.length6){alert(密码长度必须为6-12!)returnfalse}returntrue}/script/headbodyformname=myFormmethod=postaction=姓名:inputname=unametype=textvalue=p密码:inputname=pwdtype=passwordvalue=pinputtype=submitname=提交按钮value=确定onClick=returncheck();/form/body/html方法二:htmlheadmetacharset=UTF-8title登录/title/headbodyformmethod=posttabletrtd姓名:/tdtdinputtype=textname=usernameid=first/td/trtrtd密码:/tdtdinputtype=passwordname=pwdid=second/td/trtrtrtdcolspan=2align=centerinputtype=submitname=提交按钮value=提交onclick=returncheck()/td/tr/table/form/bodyscriptlanguage=JavaScriptfunctioncheck(){if(document.getElementById(first).value==){alert(姓名不能为空!)returnfalse}if(document.getElementById(second).value.length6||document.getElementById(second).value.length12){alert(密码的长度必须为6-12!)returnfalse}returntrue}/script/body/html结果截图3、显示当前时间importjava.io.IOException;importjava.io.PrintWriter;importjava.util.Date;importjavax.servlet.ServletException;importjavax.servlet.http.HttpServlet;importjavax.servlet.http.HttpServletRequest;importjavax.servlet.http.HttpServletResponse;/***ServletimplementationclassTime*/publicclassTimeextendsHttpServlet{privatestaticfinallongserialVersionUID=1L;/***@seeHttpServlet#HttpServlet()*/publicTime(){//super();//TODOAuto-generatedconstructorstub}/***@seeHttpServlet#doGet(HttpServletRequestrequest,HttpServletResponseresponse)*/protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{//TODOAuto-generatedmethodstubresponse.setContentType(text/hrml;charset=UTF-8);//设置响应输出格式,防止输出中文乱码PrintWriterout=response.getWriter();//获得向客户发送数据的输出流Datem=newDate();out.println(htmlheadtitle当前时间/title/head);out.println(style);out.println(h1{color:red;});//设置颜色为红色out.println(/style);out.println(body);out.println(h1);//以一级标题显示out.println(当前时间:+m.toLocaleString());//out.println(/font);out.println(/h1);out.println(/body);out.println(/html);out.close();}/***@seeHttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse)*/protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{//TODOAuto-generatedmethodstubdoGet(request,response);}}结果截图4、数据库的增、删、改、查(1)增加记录Insert.html!DOCTYPEhtmlhtmlheadmetacharset=UTF-8title学生信息录入页面/title/headbodyfontsize=4color=blue插入学生信息/fontformmethod=postaction=Insert.jsptabletrtdid号:/tdtdinputtype=textname=idsize=30/td/trtrtd学号:/tdtdinputtype=textname=numsize=30/td/trtrtd姓名:/tdtdinputtype=textname=namesize=30/td/trtrtd出生日期:/tdtdinputtype=textname=birthsize=30/td/trtrtdinputtype=submitname=提交按钮value=保存/td/tr/table/form/body/htmlInsert.jsp%@pagelanguage=javacontentType=text/html;charset=UTF-8pageEncoding=UTF-8%%@pageimport=java.sql.*%!DOCTYPEhtmlPUBLIC-//W3C//DTDHTML4.01Transitional//EN=Content-Typecontent=text/html;charset=UTF-8title插入学生信息/title/headbodyfontsize=4color=blue插入学生信息/font%request.setCharacterEncoding(UTF-8);StringId=request.getParameter(id);StringNum=request.getParameter(num);StringName=request.getParameter(name);StringBirth=request.getParameter(birth);Stringsql=insertintoxsbvalues('+Id+','+Num+','+Name+','+Birth+');Connectionconn=null;Statementstmt=null;try{//加载驱动Class.forName(com.mysql.jdbc.Driver);Stringurl=jdbc:mysql://localhost:3306/mysql;Stringuser=root;Stringpassword=123456;conn=DriverManager.getConnection(url,user,password);stmt=conn.createStatement();stmt.executeUpdate(sql);ResultSetrs=stmt.executeQuery(select*fromxsb);%tableborder=2trtdid/tdtdnum/tdtdname/tdtdbirth/td/tr%//利用while循环将数据表中的记录列出while(rs.next()){%trtd%=rs.getString(id)%/tdtd%=rs.getString(num)%/tdtd%=rs.getString(name)%/tdtd%=rs.getString(birth)%/td/tr%}rs.close();//关闭}catch(Exceptione){out.println(e.getMessage());}stmt.close();conn.close();%/table/body/html结果截图(2)查询记录(此例是条件查询)Select2.html!DOCTYPEhtmlhtmlheadmetacharset=UTF-8title学生信息查询/title/headbodyformmethod=postaction=Select2.jsptabletrtd请输入id号:/tdtdinputtype=textname=id/td/trtrtdinputtype=submitname=提交按钮value=保存/td/