Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About page scope objects

 
Ravi Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using following code

<%@ page import="chapter14.AddressBean" %>
<jsp:useBean id="address" class="chapter14.AddressBean"
scope="page" />
<jsp:setProperty name="address" property="*" />
<jsp:forward page="addressDisplay.jsp" />

My question is will address bean be available to addressDisplay.jsp .
If no why not and what i ahve to do to make it available in forwarded page
 
Amit Prakash Singh
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ravi,

It will not be available to "AddressDisplay.jsp" becuase you are setting attribute in page scope and it will be available in the creent page only. To make it available for the next page use either of these three scopes:

Request: attribute will be available to all resources particpating in a particular request i.e. having the same request object.
Session: attr will be available throughout the session.
Application : attr. will be availbale to every resource in your web app
 
Ravi Singh
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply .

But what if i change jsp:forward to <%@ include file = "address.jsp" %>

will then i be able to access the bean object from the includer page ?
 
Amruth Puppala
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ravi Singh:
Thanks for your reply .

But what if i change jsp:forward to <%@ include file = "address.jsp" %>

will then i be able to access the bean object from the includer page ?


Usign <%@ include file = "address.jsp" %> All the contents of address.jsp is included(pasted) in the main JSP at translation time.

Using forward th control goes to address.jsp but using include directive the control will be in the same main JSP.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic