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

Need solution for a query on JSP

 
srinivas pola
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question : Every page of your web site must include a common set of navigation menus
at the top of the page. This menu is static HTML and changes frequently, so you have decided to use
JSP's static import mechanism. Which JSP code snippet accomplishes this goal?

A. <%@ import file='/common/menu.html' %>
B. <%@ page import='/common/menu.html' %>
C. <%@ import page='/common/menu.html' %>
D. <%@ include file='/common/menu.html' %>
E. <%@ page include='/common/menu.html' %>
F. <%@ include page='/common/menu.html' %>

As per my knowledge i thought that 'F' is the correct answer as page, taglib and include are the 3 types of directives.
But 'D' is given as the solution.

Can anyone explain me why?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
F ? In JSP2.0, is there an include directive with a "page" attribute ?

(please quote your sources)
 
udaykumar maddigatla
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

include directive takes file as attribute.

jsp:include action takes page as atribute.

Here is the example

<%@ include file="...."%>

<jsp:include pae="..."/>

see the differnce, both are used to add some content in existing page. But both will follow different attribute names. One will take 'file' and other will take 'page'.
 
vikram khot
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. <%@ include file ="/common/menu.html" %> - include directive is used for page translation time it includes source code when translate page

2. <jsp:include page="/common/menu.html" > - include action is for used for request time it includes only output when its called

so your answer is - D. <%@ include file='/common/menu.html' %>
 
Kaialsh Vashisth
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1. <%@ include file ="/common/abc.html" %> include page at translation time ,so should be present at translation.

2. <jsp:include page="<%=request.getParameter("filename")%>" > - include at request time or run time , not at translation time

so your answer is - D. <%@ include file='/common/menu.html' %>
 
Milton Ochoa
Ranch Hand
Posts: 336
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
STATIC
<%@ include file="/menuBar.html" %>
<jsp:directive.include file="/menuBar.html" />

DINAMIC
<jsp:include page="menuBar.jsp" />

Burn in brain
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic