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

JSP question shared

 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wanted to share this with ranchers the answer to
HFSJ final mock exam question 63 1st ed

Given:

Assuming this is a complete JSP, which is true?
(For options E and F, ignore the fact that an error in one line might keep a
subsequent line from being reached)
A. Only line 2 will definitely generate an error.
B. Only line 3 will definitely generate an error.
C. Only line 4 will definitely generate an error.
D. Only line 5 will definitely generate an error.
E. Lines 4 and 5 will both definitely generate errors.
F. Lines 2, 3, 4 and 5 will all definitely generate errors.
G. The entire JSP could execute without generating any errors.

Answer will be G

Tell me if you think I am wrong or you are in doubt.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Parth,

Should we consider the tags (mytags) to be configured, defined and implemented well?

I would say C (lin 4 will give an error <jsp:setProperty name="x" property="a" value="b" />)

Reason: the setProperty/getProperty can be used on a bean not defined in a <jsp:useBean>. If the bean is available in the page scope. (but if it isn’t there it will result in an error 500) However it is not recommended to do so.

The <cut> tag will be ignored

Regards,
Frits
 
Parth Twari
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Frits,

Option C says that the line 4 will definetly generate an error so.. even if there is one case that the error could not be raised then we have to consider it.

Here there are two cases where error might not be generated for line 4 .

Case1: spec entry-
The object named by the name must have been “introduced” to the JSP
processor using either the jsp:useBean action or a custom action with an
associated VariableInfo entry for this name.

So the tags might have introduced it in some scope.

Case2:spec entry
If the object was not introduced in this
manner, the container implementation is recommended (but not required) to raise
a translation error, since the page implementation is in violation of the
specification.

So raising of error is container dependent.

Yes c:out will be hosed as html.
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2536
113
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
definetly generate an error

ok I fell into the trap again.... Reading the question well is part of the game

Good explanation!

Regards,
Frits
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic