Application and JavaBean Exercises

Source: Internet
Author: User

Write a JSP program that implements user registration to save user information in the Application object

1  Packagecom.sp.test;2 3  Public classUser {4 5     PrivateString usename;6     PrivateString password;7     8      PublicString Getusename () {9         returnUsename;Ten     } One      Public voidsetusename (String usename) { A          This. Usename =Usename; -     } -      PublicString GetPassword () { the         returnpassword; -     } -      Public voidSetPassword (String password) { -          This. Password =password; +     } -      PublicUser (String usename, string password) { +         Super(); A          This. Usename =Usename; at          This. Password =password; -     } -      -      -}
1<% @pageImport= "Com.sp.test.User"%>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> User's registration information </title>9Ten<body> One<% AObject obj = Application.getattribute ("Use"); - if(obj = =NULL){ -User U =NewUser ("Zhang San", "123"); theApplication.setattribute ("Use", u); -obj =u;  - } -User US =(User) obj; + //Output User Information -Out.println ("Username:" + us.getusename () + "<br> Password:" +Us.getpassword ()); +%> A</body> at

Application and JavaBean Exercises

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.