EPractice Lab mock exam 5 question 38

Himai Minh

Ranch Hand

Posts: 1361

7

posted 7 months ago

38. You are developing a Java EE application that requires a page to display dynamic chart. Which Java EE component is most suited for the above requirement?
a. Java servlet
b. JSP
c. EJB
d. DAO
Given answer : A
Although servlets and JSP pages can be used interchangeably, each has its own strengths.
Servlets are best suited for service-oriented applications (web service endpoints are implemented as servlets) and the control functions of a presentation-oriented application, such as dispatching requests and handling non-textual data.
- servlets are most effectively used for implementing logic and generating binary content.
-use servlets to implement services.
- servlets are usually not visual components, except for some that generate binary content.
- instead , think of a servlet as an information service provided by an application
- a servlet can perform whatever service it provides- templating , security, personalization, application control- and then select a presentation component (often a JSP page) to which it forwards the request for display.
- use servlets as controllers
-user servlets to generate binary content
-avoid writing servlets that print mostly static text.

JSP pages are more appropriate for generating text-based markup such as HTML, scalable vector graphics, wireless markup language and xml.

I think b is a possible choice because we can use <jsp:include page="dyamicPage.jsp"/> to include dynamic content in a page.