• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Mock test doubt in jsp

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ranchers;

In following example i tried this code and while deploying this code in jsp i found there was nothing on that page....

That means answer shoud be 2...But answer for following question is given as 4

I found the same issue in different mock test so if i et this type of question in exam then what to answer...

What will be the result of this jsp line if the user takes a look at the page source code?
<!-- Today is <%= new java.util.Date() %>.Hava a nice day -->

1) It won't compile
2) The user won't see the comment
3) The user will see the same jsp line as above
4) The user will see the comment with the current date because the expression is evaluated at runtime.

Regards;
Brijesh
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brijesh,

The correct answer is 4.

This question is more on the JSP comments vs HTML comments.

As you said, the output is blank. However, if you see the source code of the page, then you will realize that its not blank. The expression is executed and date is displayed. Because of the HTML comments it is not visible in the browser. So user can see the comment (via source code ) hence answer 4 is correct.


If the code would have been in JSP comments then answer 2 would have been correct. <%-- JSP comment text --%>


Cheers,
Atul Samnerkar
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brijesh

As per the question - "would the user see the time if he sees the source " & i think the answer is yes. Trigger this jsp from ie & right-click -> view source, you would find the current datetime there. So i agree the answer to the question is option d.

Regards,
Abilash
 
Brijesh shah
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks i got it
 
reply
    Bookmark Topic Watch Topic
  • New Topic