• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

syntax related

 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
21.Which of the following are valid JSP scriptlets?
Select 2 correct options.
A.<% String uid = LoginHelper.login(request) %>
B.<% String uid = LoginHelper.login(request); %>
C.<%! String uid = LoginHelper.login(request) %>
D.<%@ String uid = LoginHelper.login(request) %>
E.<% for(int i=0; i< 10; i++) { out.println(i); } %>


The above Question i got from mock exam in which they have given correct answers are B and E... But i think answer should be A and E...So please explain me if i'm wrong.

Thanks;
Brijesh
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Brijesh,

I think answers B, E are correct...



is a declaration of a variable.

This declaration could either be an instance variable or a
variable local to the service() method of the servlet that
is generated out of the jsp.

Answer B generates the local variable in the service() method.

Answer C generates the instance variable, but the request variable
is not known outside the service() method.

Answer E is correct as well, but does something else.

A and D are wrong as well, because A misses a semicolon at the end
of the declaration, and D is not a proper declaration.

Kind regards,

Gian
[ January 10, 2008: Message edited by: Gian Franco ]
 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i got it.
[ January 10, 2008: Message edited by: Brijesh shah ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic