• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

web components certification question

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What modifications should be made in test.jsp to make the employee bean accessible within another jsp.
test.jsp
<jsp:useBean ud="employee" class="EmployeeBean"/>
<jsp:include page="another.page"/>
another.jsp
<jsp:getProperty name="employee" property="salary"/>

Correct answer is: modify the code to use the include directive instead of include action.
Explanation is: By default the scope of the bean is page, so the bean will not be available when the include directive is used. Why?
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please QuoteYourSources.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a difference in the way the include directive & <jsp:include> standard action work. Include directive actually includes the source of the included file while <jsp:include> standard action includes the response of the included page. You can have a look at the container generated servlets for the JSPs implementing both these options for a deeper understanding.
 
galina bloch
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought it has something to do with the page scope.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

galina bloch wrote:I thought it has something to do with the page scope.


Please QuoteYourSources.
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
galina don't ignore Christophe's request to quoting source of the question. Mentioning the source of mock exam questions is mandatory at javaranch...
 
galina bloch
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
source: whizlabs mock test
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Nilesh said, the two include techniques are different. The include directive puts the contents of the included page directly inside of the JSP when it is translated into Java code and compiled. This means that if the included page contains dynamic content, it will never change (because it was evaluated only once). The include standard action includes the page every single time so that dynamic content shows up. So the include directive is better for static content and the include standard action is better for dynamic content.

Because the include directive puts the contents of the file directly inside of the JSP, you can use page scope.

index.jsp:
another.page.jsp:


But if using the include standard action, you must use request scope because the included page exists in a separate page scope.

index.jsp:
another.page.jsp:


I hope that helps you..
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic