1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="Utf-8"Import="java.util.*" %>3 <%@ Page Import="java.sql.*" %>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>User Forms</title>9 </Head>Ten <Body> One <Center> A <formAction= "setpropertydemo.jsp"Method= "POST"> - <Table> - <TR> the <TDcolspan= "2">User Forms</TD> - </TR> - <TR> - <TD>User name:</TD> + <TD><inputtype= "text"name= "username"></TD> - </TR> + <TR> A <TD>Dense Code:</TD> at <TD><inputtype= "Password"name= "UserPassword"></TD> - </TR> - <TR> - <TDcolspan= "2"> - <inputtype= "Submit"name= "Submit"> - <inputtype= "Reset"name= "Reset"> in </TR> - </Table> to </form> + </Center> - </Body> the </HTML>
This form simply implements the parameter passing of the user name + password.
After the page submits a user name and password, it jumps to another page setpropertydemo.jsp, outputting the submitted user information.
The code for SETPROPERTYDEMO.JSP is as follows:
1 <%@ Page Language="Java"ContentType="text/html; Charset=utf-8"2 pageencoding="Utf-8"Import="java.util.*" %>3 <%@ Page Import="java.sql.*" %>4 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">5 <HTML>6 <Head>7 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8">8 <title>Setting the JavaBean Property</title>9 </Head>Ten <Body> One <Jsp:usebeanID= "User"Scope= "page"class= "Chapter7." UserBean "></Jsp:usebean> A <Jsp:setproperty Property="*"name= "User"/> - <% - Out.println ("User name:"+User.getusername ()+"<br/>"); the Out.println ("User password:"+User.getpassword ()); - %> - </Body> - </HTML>
Simple implementation of JSP user forms