1, JavaBean
The so-called JavaBean is a Java class that satisfies certain design rules, and the rules to be met are as follows
(1) The attribute of the data member is private
(2) Setxxx and GetXXX methods for each data member that has the public attribute
(3) A constructor for a public type with no parameters
2. Instance Code
Package Bean;public class Usercheckbean{private string Name;public Usercheckbean () {}public Usercheckbean (String name) { This.name=name;} public void SetName (String name) {this.name=name;} Public String GetName () {return name;} public Boolean validate () {return name.equals ("CJC");}}
Login interface
<! DOCTYPE html>
Validating JSPs<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 " pageencoding=" Iso-8859-1 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" ><%@ page Import= "Bean. Usercheckbean "%><jsp:usebean id=" user "scope=" session "class=" Bean. Usercheckbean "/><jsp:setproperty name=" user "property=" name "value=" * "/><%string nm= Request.getparameter ("name"); User.setname (nm); Usercheckbean uc=new Usercheckbean (nm), if (Uc.validate ()) {%><jsp:forward page= "welcome.jsp"/><%}else{ Out.println ("The username does not exist!"); o Ut.println ("<a href=\" login.html\ ">login again</a>");} %>
Welcome interface<%@ page language= "java" contenttype= "text/html; Charset=iso-8859-1 " pageencoding=" Iso-8859-1 "%><! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd" >
JSP Form Fill Validation---Jsp+javabean