Professional Documents
Culture Documents
0) [Scwcd_orkut Folder]
By-Shubham Roy
Mail me :- escortnotice@yahoo.co.in
Try Visiting-www.sec2ndchance.wordpress.com
Some Answers or explainations might be incorrect.So do verify them and don’t rely on my
explainations fully as I am a newbie too and not an expert….
Note:- The Page numbers are from Head First Servlet and Jsp (2nd Edition).
Symbols:-
*-I don’t know the answer and couldn’t find any reference.
1) The question says JSP Document hence option hence option D is correct as it is a JSP
Document Syntax. Option A is a JSP page syntax .Option B&C has are syntactically wrong . [Pg
629,pg 287,314,pg 315.]
3) Option D is correct but this was used in old JSP (before JSP 2.0) but not in new JSP 2.0. (Pg
485).
4) Pg 298
5)
The JSP page is converted to Servlet and then it follows the life cycle of a Servlet. (Pg 283,97)
5. jspInit is called
6. _jspService is called
7. jspDestroy is called
6)
The include Directive<%@ include file=’foo.jsp’/> happens at translation time but the<jsp:include>
happens at runtime.As the question says translation time hence the above answer is applicable. (Pg
403,404,405,406)
7)By specifying the attribute isThreadSafe to false you want the generated servlet(jsp gets
translated into servlets) to use the SingleThread Model.(Pg-315)
The answer is A bcoz, the doStartTag() method is returning SKIP_BODY which means the body of the
tag shud not be evaluated.Hence the doAfterBody() method wont get executed .
9)*
10)As its been set in the request scope hence we need to get it through the request object’s
getattribute() method and type cast it to String.
11)*
12)*
13)servlet context object is available to all servlets in one web appllication.servlet config is available
to only one servlet.Session is available to all the servlets.Only httpservletrequest exists between
two servlets i.e-the servlet which forwards the request and the servlet which receives the
request,hence this is the answer.
14)pg-182, There is nothing called ContextListener.its ServletContextListener and the methods used
are contextInitialized() and contextDestroyed().
15)answers are self explainatory.All about servletcontext listener are given in pg-166.
17)pg 719
18)pg-206,207.You cannot forward a request if you have already committed a response.line 19 causes
the response to be sent to the client.Hence a request cannot be forwarded as it is finished or is
history,bcoz u hav responded.
20)the session object is destroyed and hence it cannot be used to retrieve a value stored in it.
22)self
23)self,pg-182
24)self
25)*
26)*
27) news:lookup tag should be nested and a news headline which is printed by news:item should be
in a new row hence C is the right answer.
28)self,pg 465
29)self,pg455
30)<c:forTokens>,it lets you iterate over tokens where you give it the delimiter.
31)self
32)*
33)self
33)self
34)557,559,561
35)pg664,675
36)pg 665,666
37)679
38)*
39)pg 675
40)self,pg665
41)618,619
42)
<mime-mapping>
<extension>mpg </extension>
<mime-type> video/mpg</mime-type>
</mime-mapping>
Pg-633
43)630,631
44)*
45)pg-614
47)pg-612
48)pg-622,623
49)for EL expressions The only way to acess the request object is by going thru the pagecontext
implicit object.requesturi is a propert y of request object hence to access it we need the request
object.pg-385,388,
50)pg-396,398,399.request scope is used to get request attributes and not request property.For
eg-request.setattribute(“foo”,4).In this foo is a request attribute. Similarly if we write request.
requestURI ,here requestURI is a request property that is,requestURI is a variable which might store
some value and is a part of the request object.
51)Pg-390
Now as the function returns a map,hence the returned value would be an object as a map stores
objects. And in order to access some property if that object we would write object.property henc
option f is applicable as ${foo.function(3)} will return an object stored at 3rd place in the map and
${foo.function(3).name} will give access to the name property of that object.
53)*
54)pg 753
56)pg-754
57)pg 759
59)pg754
60)
Getservletpath /control
getpathInfo /processorder
getContext /myapp
62)self
63)pg-251
64)pg-123
65)pg-132
66)pg-323
67)
<jsp:useBean
id= ‘catalog’
type=’java.util.list’
scope=’application’
/>
Pg 348,356
69)*
70)pg 251.
Response.addCookie(cookie);
Or
Response.addCookie(new Cookie(“username”,”joe”));
setContentLength-*
73)pg 253
74)pg-122
76)pg-626
77)pg-608
78)*
79)pg-64
80)pg-632
81)self
82)*
83)
|___JSP files Static content
|___WEB-INF
|___classes
|____ lib
|____ web.xml
Pg-608
85)pg-294
86)*
88)Scripting is invalid but scripting code is their hence jsp doesn’t execute.
89)*
90)pg-287
91)Pg-473
92)pg-485
94)*
95)*
96) pg-456
It adds to a hash map named resultMap with key as the value stored in results[0].name and value in
results[0].value and results[0] stores an object.
97)pg-475
98)we use uri when we have a tld file.Hence we can make a tld of a tag file and add to the web
application.Tld files generally help the container and a JSP developer how to use the tag.
Pg-483
99)self
100)pg-257(Session migration)
101)pg-182
102)pg-182
103)pg-239
104)pg-244,245
105)pg-234
106)pg-665
107)682,684
109)pg-669
111)authentication is in pg 677
112)pg-371,372,373,379
113){not map.c} is always true. map.d has null value hence a null with or true is true.similarly true
and null is true.
114) pg-386
115)pg-390
116)pg-393
117)see 569.The example is for classic tag handlers but it also applies to simple tag handlers.
120)pg-531,532,533
121)pg-482
122)pg-754
123)pg-759
124)pg-754,759
126)pg-769
128)*
129)self
130)pg-182
132)pg-182
133)pg-711
134) a request object is only accessible to the servlet or jsp to which it has been forwarded.
135)pg-358
136)pg-412
137)pg-357
137)pg-357
139)pg-97
Calls init()
Calls service()
Calls destroy()
140)pg-133
141)*
142)pg-252
144)pg-109
145)pg-403
146)*
147)pg-321
148)*
149)pg-235
150)in a servlet life cycle init() is called once.Similarly static block is executed once.and initializer
block is also executed once.
D is correct.
153)pg-370 onwards.
154)pg-471,473
155)pg-393
156)pg377
157)pg-513,514
158)pg-563,564
159)*
160)*
161)*
162)pg-360
163)pg-349,356
165) pg-349,356
166)*
167) pg-665
168) pg-684
169) pg-677
170)pg-656
171)pg-684
172)pg-509
174)pg-456
175)pg-443
176)the tag has a body content scriptless hence option D will give an error as it has a scripting in its
body.
177)pg-463
178)pg-483
179)pg-454
181)self
182)pg-182
183)Servlet Context parameters cannot be set programmatically.
184)*
185)pg708
186)*
187)pg-613
188)pg-626
189)*
190)*
191)pg628
192)pg-626
194)pg-630
195)*
196)pg-235
197)self
198)self
199)pg-182
200)pg-244
202)self
205)pg-754
206)self
208)self
209)pg-769
210) pg-753
211) pg-753
212)self
214)pg-618,619
/data/-Data Servlet
/data/index.jsp-Data Servlet
/secure/command.do-control servlet
/data/command.do-Data servlet
/data.do-controlservlet
215)all files under Meta-inf and web-inf dir are not accessible directly.
216)self
217)pg-154
Here we are using servlet config parameters.As the remote ip is handled by only one servlet hence
servlet config parameters is suitable.
218)pg-615,3rd question
220)*
221)pg-622,623
222)pg-362,363.option c is similar to page 360,but in param here they have used EL.for EL exp see
page 386.
223)here the only the value that is 49.95 is set but the name is not.so it will take the name that is
assigned whn its object is created i.e-default.
To know more abt usebean go to page-349 and to know abt set property go to page-351
225)pg-404.As the three are stored in the request object hence we can use EL to retrieve it.
226)pg-577
227)*
228)pg-532
229)pg-510(see question 1)
230)*
231) pg-666,pg-669
232)pg-666
233)pg-666
234)pg-665
238)*
239)pg-244
240)pg-238
241)pg-182
242)self
243)*
244)*
245)*
247)pg-458
248)pg-486
249)pg443,445
250)*
251)pg-446,pg-448
252)self
254)self
255) pg-322
257)pg-412
258)*
259)self
260)pg-390
261)pg706,707
262)pg-168
<listener>
<listener-class> </listener-class>
</listener>
264)self
265)*
266)pg-253
267)120 days=120*24*360=10368000
268)refer Q)60
269)pg-109
271)*
272)pg-369,371
273)pg-373
274)pg-386
275)*
276)self