JavaBean is a Java class, referred to as a bean, that has a feature or ability to handle a business by encapsulating properties and methods. For example, you can create a user's Bean class:
This class is actually a model class, involving some properties on the page, such as Name,sex, and provide the Get/set method of these properties, this is a simple bean class.
The first thing we need to do is to get the properties we want from a page, and if we always get the parameter values in a Request.getparameter () way, it doesn't fit the idea of object-oriented, so we need to form a javabean.
First look at the registration interface, we want to get the registration interface after the submission from the interface to obtain some data, the code is as follows:
Then look at the login interface, in this JSP interface we use the JavaBean technology, the code is as follows:The first thing we need to do is to import the Bean class we need in the <%@ page%> tag, that is, user:import= "Com.model.User", and then we use the <jsp:useBean> tag for JavaBean, The property has an ID property, which allows us to get all the property values in the whole bean, and the scope property, which is to use the El object, get the object property in what range, class property, corresponding instance Bean class. We then use the <jsp:setProperty> tag to get the property we need, which contains the property attribute, which corresponds to the Name property in ${requestscope.user.name}, corresponding to the <jsp :usebean> the id attribute in the tag, the Param property, corresponding to the registration interface you need to get the name of the property.
JavaBeans Development of JSP