| Author |
Question about include
|
Win Yu
Ranch Hand
Joined: Oct 17, 2001
Posts: 224
|
|
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).]
|
Win
|
 |
ruijin yang
Ranch Hand
Joined: Apr 29, 2001
Posts: 96
|
|
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
|
SUN Certified Business Component Developer Java EE Platform 5 (2008)<br />SUN Certified Developer for Java Web Services (2007)<br />IBM WebSphere Portal V5.1 Application Development (2006)<br />SUN Certified Web Component Developer (2001)<br />SUN Certified Java 2 Programmer (2001)
|
 |
Peter den Haan
author
Ranch Hand
Joined: Apr 20, 2000
Posts: 3252
|
|
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 ]
|
 |
 |
|
|
subject: Question about include
|
|
|