ForNameServlet
package cnimport javaimport javaimport javaximport javaximport javaximport javaxpublic class FornameServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html;charset=utf-8"); PrintWriter ((((" <BODY>"); String name = request.getParameter("ForName"); if(name!=null&&!name.trim().equals("")&&name.startsWith("hncu")){ request.setAttribute("error", 1); }else{ request.setAttribute("error", 0); } request((()(); } }画中画 reg.jsp
="text/javascript"> var res =<%=request.getAttribute("error")%>; var olabel = window.parent.document.getElementById("label"); if(res!=null){ if(res==0){ olabel.style.color = "red"; olabel.innerHTML="用户名字存在,请换一个"; }else{ olabel.style.color = "green"; olabel.innerHTML="恭喜你!该用户名可以使用!"; } } // 技术二 调用父类方法 // parent.back(res); </script>