1 PackageJavaBean;2 3 Public classJavaB2 {4 PrivateString name= "Lhy";5 Private intXuehao=123;6 PrivateString banji= "First Grade One class";7 PublicString getname ()8 {9 returnname;Ten } One Public voidSetName (String name) A { - This. name=name; - } the Public intGetxuehao () - { - returnXuehao; - } + Public voidSetxuehao (intXuehao) - { + This. xuehao=Xuehao; A } at PublicString Getbanji () - { - returnBanji; - } - Public voidSetbanji (String Baji) - { in This. banji=Banji; - } to}
1<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "2pageencoding= "UTF-8"%>3<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >456<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">7<title>insert title here</title>89<body>Ten<form action= "javabean2.jsp" mothod= "POST" > One<br> AUser name <input type= "text" name= "username" > -<br> -Password <input type= "password" name= "password" > the<br> -<input type= "Submit" value= "Login" > -</form> -</body> +1<% @pageImport= "JAVABEAN.JAVAB2"%>2<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "3pageencoding= "UTF-8"%>4<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >567<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 ">8<title>insert title here</title>9Ten<body> One A<% -JavaB2 jb2=NewJavaB2 (); -Out.print ("Name:" +jb2.getname ()); theOut.print ("<br>" + "Study No.:" +Jb2.getxuehao ()); -Out.print ("<br>" + "class:" +Jb2.getbanji ()); -%> -</body> +Jsp-javabean Exercise 1