Jsp Tutorial Home

Jsp Home

JSP Resources

Community

Site

Request Bean Scope Example

text zoom

Request Bean Scope Example


The previous example is used and extend it to the request scope. We will set the property in one page and get the property in the next page. From first page we will forward the request to second page.









requestbeanscope.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>Insert title here</title>

</head>

<body>

<jsp:useBean id="person" class="com.visualbuilder.beans.Person" scope="request"/>

<jsp:setProperty name="person" property="name" value="Chris"/>

<jsp:setProperty name="person" property="age" value="18"/>

<jsp:forward page="requestbeanexample1.jsp"/>


</body>

</html>










requestbeanscope1.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>Insert title here</title>

</head>

<body>

<jsp:useBean id="person" class="com.visualbuilder.beans.Person" scope="request"/>

The name is :- <jsp:getProperty name="person" property="name" /><br/>

The age is :- <jsp:getProperty name="person" property="age" /><br/>


</body>

</html>



Output:-


                    

Copyright © 2012 VisualBuilder. All rights reserved