//----------------------userRegister.jsp <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.util.*"%> <html><head><title>userRegister.jsp</title> <SCRIPT language=javaScript> function formcheck(Fm) { var flag=true; if(Fm.id.value=="") { alert("您沒有輸入賬號,請從新輸入!"); Fm.id.focus(); flag=false; } return flag; } </SCRIPT> </head> <body> <form name="Fm" method="post" action="registerSuccess.jsp" onsubmit= " return formcheck(this)" > <input name="id" type="text " value= "" > <input type="submit" name="Submit" value="提交" > <input type="reset" name="Submit" value="重置"> </form> </body> </html>
//--------------registerSuccess.jsp <%@ page contentType="text/html;charset=gb2312" %> <%@ page import="java.util.*"%> <html><head><title>registerSuccess.jsp</title></head> <body> <% String id=request.getParameter("id").trim(); //String pwd=request.getParameter("password"); //String checkPwd=request.getParameter("checkPwd"); //String name=request.getParameter("name").trim(); if(id.equals("111")) { response.sendRedirect("userRegister.jsp"); } String username =request.getParameter("id"); out.println("歡迎訪問:"); byte b[]= username.getBytes("ISO-8859-1"); String str=new String(b); %> <%=str%> </body> </html>