This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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 :
------------
<html>
<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" />
</body>
</html>
----------------------------------------------------
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()) {
worker2.store();
%>
<br>
<jsp:getProperty name="worker2" property="guesser" />, your choices have
been stored.<br> Here they are:<br>
<table border cols=5 width="75%" >
<caption></caption>
<tr>
<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>
</tr>
</table>
<br>
<% } 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
 
author
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic