jQuery in Action, 2nd edition*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes JSP Without going to server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "JSP Without going to server" Watch "JSP Without going to server" New topic
Author

JSP Without going to server

Sandeep Vaid
Ranch Hand

Joined: Feb 27, 2006
Posts: 390
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

Joined: Mar 30, 2007
Posts: 77
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


SCJP5 95%, SCWCD 85%<br />Knowledge is the Life of Mind
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60822
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP Without going to server
 
Similar Threads
displaying sql query results
calling a java Script file into the Jsp
question about session?
QUESTION ID: 1078868194546 - JWebPlus
Good Quesion