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

Q.20 from Head First Chapter-9 Scriptless JSP

 
James Winfrey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys


This is Q.20 from Head First Chapter-9 Scriptless JSP.

The correct answers are C and D.

Why is choice D correct?


A web based application for a major online movie rental retailer stores a
List<Movie> as a session attribute to contain movies the user has requested.

A random, embedded movie trailer from this list must display on the users’
main page every time the users’ main page is viewed.

Management thinks a similar feature will be needed in the near future on
other pages that display lists of movies. Streaming video is accomplished with
regular HTML, just like adding images to a page but with more complex tags.

The development team needs a solution that is both flexible and maintainable.

One possible solution is to create an EL function. The following statements
are from a team meeting concerning EL functions as a solution to this
problem. Which statements are true?

(Choose all that apply.)

A. EL functions can not solve this problem because they can not retrieve
session attributes.
B. The method implementing the EL function should not be declared
static to give it access to session scope.
C. The EL function can accept a parameter of java.util.List
which will allow the needed movie list to be passed to it using EL.
D. You might have to write HTML tags in the middle of Java code using
an EL function, which is more difficult to maintain.
 
Ankit Garg
Sheriff
Posts: 9580
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 parts in option D, one says that you'll have to put HTML inside java code and the other says HTML within java code is difficult to maintain. Which part of this is not clear to you can you please tell...
 
James Winfrey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ankit. I have doubt in putting HTML inside Java. We can call the jsp.
 
Parambir Singh
Ranch Hand
Posts: 40
Android Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James

Let's assume that to stream the video on the homepage, you have to use an HTML tag such as

Now, if you want to write an EL function, it'll have to create the <video> tag using Java code. For example:



This is what option D is referring to. Now, if in future the video tag's attribute names change, you'll have to modify your EL function and recompile your code.

Hope it helps!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic