Step-by-step Jsp + JavaBean tutorial (6)

Source: Internet
Author: User
Tags microsoft frontpage
This section involves two pages. One donewuser. jsp file is used to add records, and the other listuser. jsp file is used to add records.
Displays information about all registered users. The two pages involve the specific call of JavaBean. Let's take a look at the file,
Comments are added to key code in the file for your understanding.
Donewuser. jsp file
Note: the user registration operation page displays the corresponding feedback based on whether the user registration is successful. The main feature of this page is to use
The addNewUser () method of the JavaBean lyf. adduser method is used to add records.
<% @ Page contentType = "text/html; charset = gb2312" %>
<% Response. setHeader ("Expires", "0"); %>
<! -- Generate a JavaBean: lyf. adduser instance. The id is adduser and the survival range is page -->
<Jsp: useBean id = "adduser" class = "lyf. adduser" scope = "page"/>
<! -- Set the values of each attribute in the JavaBean, which calls the set method of each attribute in the JavaBean to obtain
The correct attribute value. "*" indicates matching all attributes -->
<Jsp: setProperty name = "adduser" property = "*"/>
<Html>
<Head>
<Meta http-equiv = "Content-Language" content = "zh-cn">
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta name = "GENERATOR" content = "Microsoft FrontPage 3.0">
<Meta name = "ProgId" content = "FrontPage. Editor. Document">
<Title> add a user </title>
</Head>
<Body bgcolor = "# FFEBBD">
<Div align = "center"> <center>
<%
// Call the checkUser () method of lyf. adduser to check whether there are duplicate usernames
// If there are duplicates, the corresponding information is displayed.
If (! Adduser. checkUser ())
{
// Page text output information, using the println method of the embedded jsp object out, equivalent to the response. write method in asp
Out. println ("Sorry, this user name" + adduser. getUsername () + "has been applied. Please reselect it! ");
// Return indicates that the return is returned, and the following processing will not be performed when the return is run. The function is equivalent to response. end in asp.
Return;
}
%>
<%
// If no duplicate user names exist, call the addNewUser () method of lyf. adduser to add user data to the database, and
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.