• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Question about include

Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two JSP files. Even I did not put "<jsp:useBean id="worker2" class="com.wrox.projsp.ch07.BabyGameWorker2" scope="request" />" at the begining in the second file, it works, WHY??
first file :
<head><title>Baby Game - Your Guesses</title></head>
<body bgcolor="#FFFFFF">
<%@ page language="java" buffer="8k" %>
<jsp:useBean id="worker2" class="com.wrox.projsp.ch07.BabyGameWorker2" scope="request" />
<jsp:setProperty name="worker2" property="*" />
<jsp:include page="/web/mediatorcompositeview/compositeinclude.jsp" flush="true" />
second file:compositeinclude.jsp
<!-- <jsp:useBean id="worker2" class="com.wrox.projsp.ch07.BabyGameWorker2" scope="request" /> -->
I did not put use bean at the begining.
<%@ include file="nestedheader.html" %>
<% if(worker2.validate()) {
<jsp:getProperty name="worker2" property="guesser" />, your choices have
been stored.<br> Here they are:<br>
<table border cols=5 width="75%" >
<td><jsp:getProperty name="worker2" property="gender" /></td>
<td><jsp:getProperty name="worker2" property="pounds" /> lbs
<jsp:getProperty name="worker2" property="ounces" /> oz</td>
<td><jsp:getProperty name="worker2" property="month" />
<jsp:getProperty name="worker2" property="day" /></td>
<td><jsp:getProperty name="worker2" property="length" /> inches</td>
<% } else { %>
<br> There where some choices that were not selected.<br><br>
Sorry, but you must complete all selections to play.<br>
<font size=-1>(Please hit the browser 'back' button to continue)</font><br>
<% } %>
[This message has been edited by Win Yu (edited November 15, 2001).]
[This message has been edited by Win Yu (edited November 15, 2001).]
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Win,
I think the bean's scope is "request".The included page belongs
to same request as the including page.So it works.If you change
scope to "page".I do not think it works again.You try it.
ruijin yang
Posts: 3252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works because you are using an include directive, which works much like the #include which we all know and love from the C preprocessor. Both files are merged into one compilation unit.
Try changing it into a dynamic include action (<jsp:include>) .
- Peter
[ April 10, 2002: Message edited by: Peter den Haan ]
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic