package javaBean; public class JavaB2 {
private String name="lhy";
private int xuehao=123;
private String banji="一年级一班";
public String getname()
{
return name;
}
public void setname(String name)
{
this.name=name;
}
public int getxuehao()
{
return xuehao;
}
public void setxuehao(int xuehao)
{
this.xuehao=xuehao;
}
public String getbanji()
{
return banji;
}
public void setbanji(String baji)
{
this.banji=banji;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="javabean2.jsp" mothod="post">
<br>
用户名<input type="text" name="username">
<br>
密码 <input type="password" name="password">
<br>
<input type="submit" value="登录">
</form>
</body>
</html>
<%@page import="javaBean.JavaB2"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body> <%
JavaB2 jb2=new JavaB2();
out.print("姓名:"+jb2.getname());
out.print("<br>"+"学号:"+jb2.getxuehao());
out.print("<br>"+"班级:"+jb2.getbanji());
%>
</body>
</html>