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..
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.
SCJP5 95%, SCWCD 85%<br />Knowledge is the Life of Mind
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.