JavaBeans Development of JSP

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.