• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP Without going to server

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the HD book,

Select the correct statement about the following code. (Select one)
<%@ page language="java" %>
<html><body>
out.print("Hello ");
out.print("World ");
</body></html>
a It will print Hello World in the output.
b It will generate compile-time errors.
c It will throw runtime exceptions.
d It will only print Hello.
e None of above.
Answer: e
Explanation
The lines out.print("Hello ") and out.print("World ") are not contained
in a scriptlet (<%...%> . The JSP engine assumes they are a part of the
template text and sends them to the browser without executing them on the
server.
Therefore, it will print the two statements in the browser window:
out.print("Hello ");out.print("World ");


According to me the line in bold is not correct. The request will go to the server. I kept a RequestListener in between & it goes in requestInitialized() method confirming that the eues goes to the server..
 
saqib sarwar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are wrong Sandeep, question and answer are correct.

actually if your code does not contain any scriptlets does not means that your request will not go to the server. it will go to the server in any case. so requestlistener will always work whenever any client access/request for any part of you application.

Kind Regards
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP engine assumes they are a part of the
template text and sends them to the browser without executing them on the
server.


This line does not say that the request will not go to the server; of course it will. It says that what looks like Java in the file will not be executed on the server since it is template text, not scriptlet code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic