Saturday, 28 February 2015

Program for jsp usebean

index.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Index</title>
</head>
<body>
<form action="welcome.jsp" method="post">
<h3>Enter your user name and password</h3>
Name <input type="text" name="uname"/><br>
password <input type="password" name="pass"/><br>
<input type="submit" value="Register" />
</form>
</body>
</html>

welcome.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Process</title>
</head>
<body>
<jsp:useBean id="t" class="com.getset.Info"></jsp:useBean>
<jsp:setProperty property="*" name="t"/>

Your User Name and password is<br>
<jsp:getProperty property="uname" name="t"/><br>
<jsp:getProperty property="pass" name="t"/>
</body>
</html>

info.java

package com.getset;

public class Info {
   
    String uname,pass;

    public String getUname() {
        return uname;
    }

    public void setUname(String uname) {
        this.uname = uname;
    }

    public String getPass() {
        return pass;
    }

    public void setPass(String pass) {
        this.pass = pass;
    }

}





No comments: