-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathPRJ321.txt
952 lines (951 loc) · 191 KB
/
PRJ321.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
For what reason does the following JSP fail to translate and compile?<html><body><%!intx%><%=x;%></body></html> | Error in JSP Expression.
Study the statements:1) URL rewriting may be used when a browser is disabled cookies. 2) In URL encoding the session id is included as part of the URL. | Both 1 and 2 are true
JavaBeans component has the following field: | a. public void set Enabled(boolean enabled) public boolean getEnabled()
You have declared a useBean tag as: <jsp:useBean id="man" class="animal.Human" scope="application"/> In which type of object will this bean be kept? | ApplicationContext
What gets printed when the following code snippet is compiled? select the one correct answer. <%int y=0;%> <%int z=0;%> <%for(int x=0;x<3;x++){%> <%z++;y;%> <%}%> <%if(z<y){%> <%=z%> <%}else{%> <%=z-1%> <%}%> | a. 2
What is the result of attempting to access the following JSP page? <html> <body> <%!public String methodA(){ return methodB();} %> <%!public String methodB(){ return "JAD Final Test"; } %> <h2><%= methodA() %></h2> </body> </html> | a. "JAD Final Test" is output to the resultring web page.
What is output to the web page on the second access to the same instance of the following JSP? <html> <body> <%int x=0;%> <%= x++ %> </body> </html> | a. 0
The requirement for an online shopping application are: It must support milions of customers. The invocations must be transactional. The shopping cart must be persistent. Which technology is required to support these requirements? | a. EJB
Which of the following lines of code are correct? | a. @Entity public class Employees{..}
______________ beans have a higher level of reuse | Entity beans.
message-driven bean are stateful. | b. False
Which is the correct statement? | You can use cmp and bmp beans in the same application.
Study the statements about web.xml file: 1)The deployment descriptor file is called web.xml, and it must be located in the WEB-INF directory. 2)web.xml is in XML (extended markup language) format. Its root element is <web>. | a. Only statement 1 is true
Study the statements:1)URL rewritng may be used when a brower is disabled. 2)In URL encoding the session id is included as part of the URL. | a. Both 1 and 2 are true
What gets printed when the following JSP code is invoked in a brower. Select the one correct answer. <%= if(Math.random() < 0.5 %> hello <%= }else{ %> hi <%= } %> | a. The JSP file will not compile.
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The InventoryItem class has private instance variables to store the item information: 10. private int itemId; 11. private String name; 12. private String description; Which method signature follows the JavaBeans naming standards for modifying the itemId instance variable? (Choose one.) | a. setItemId(int itemId)
Which of the following correctly represents the following JSP statement. Select the one correct answer | a. <jsp: expression>x</jsp: expression>
Which of the following methods can be used to add cookies to a servlet reponse? | a. HttpServletResponse.addCookie(Cookie cookie)
Create() method of entity home interface returns ________ | a. Remote object
Which of these is a correct fragment within the web-app element of deployment descriptor? Select the two correct answers. | <error-page><error-code>404</error-code><location>?error.jsp</location></error-page>
A ______________has a name, a single value, and optional attributes such as a comment, path and domain qualifiers, a maximum age, and a version number. | Cookie
In EJB2.0, ejb-jar.xml deployment descriptor file must be placed in ______________folder | META-INF
Study the statements: The special directory/WEB-INF/lib contains Java class files-servlets and supporting code. The special directory/WEB-INF/class contains JAR files with supporting libraries of code. | Both1 and 2 a not true
Which of the following files is the correct name and location of deployment descriptor of a web application? Assume that the web application is rooted at\doc-root. Select the one correct answer | \doc-root\WEB-INF\web.xml
Which of these are legal return types of the doAfterBody method defined in a class that extends TagSupport class. Select two correct answers | a. EVAL_BODY_AGAIN b. SKIP_BODY
Which of these is legal return types of the doEndTag method defined in a class that extends TagSupport class? Select two correct answers. | a. EVAL_PAGE b. SKIP_BODY
Name the class that includes the getSession method that is used to get the HttpSession object. | HttpServletRequest
To send text output in a response. The following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer | a. getOutputStream
What is the result of attempting to access the following JSP page? (Choose one.) <html> <body> <%!public String method(){ Return�JAD Final Test�; } %> <h2><%=method()%></h2> </body> </html> | �oeJAD final test� is output to the resulting web page.
Which of the following statements are correct about the status of the Http response? Select the one correct answer | A status of 200 to 299 signifies that the request was successful.
A bean with a property color is loader using the following statement <jsp:usebean id=�fruit� class=�Fruit�/> Which of the following statements may be user to print the value of color property of the bean? Select the one correct answer. | a. <jsp:getProperty name=�fruit� property=�color�/>
The _________________ supplies business components, of enterprise beans | Bean provider
Which of the following are potentially legal lines of JSP cource?(Choose two.) | a. <jsp:useBean id=�beanName1� class=�a.b.myBean� type=�a.b.Myinterface�/> b. <isp:setProperty name=�beanName1� property=�soleProp� value=�<%=myValue%>�/>
Which of the following represents the XML equivalent of this statement <%@ include file=�a.jsp�%>. Select the one correct statement. | a. <jsp:directive.include file=�a.jsp�/>
Which of the following direcrories are legal locations for the deployment descriptor file? Note that all paths are shown as from the root of the machine or driver.(Choose one.) | /appserverIntallDirectory/webapps/webappName/WEB-INF/xml
Which are EJB containers? (choose three) | a. JBoss b. IBM WebSphere c. BEA’s WebLogic
Study the statements: URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL. | a. Both 1 and 2 are true
ejbCreate() method of entuty bean class returns ________________ | primary key
Name the implicit variable to JSP pages that may be used to access all the other implicit objects | pageContext
Study the statements about web.xml file: The deployment descriptor file is called web.xml, and it must be located in the WEB_INF directory . Web.xml is in XML (extended markup language) fomat. Its root element is <web>. | Only statement 1 is true.
A java bean with a property color is loaded using the following statement <jsp:usebean id=�fruit� class=�Fruit�/> What is the effect of the following statement <jsp:sentproperty name=�fruit� property=�color�/> Select the one correct answer. | If there is a non-null request parameter with name color then its value gets assigned to color property of Java Bean fruit
In ejb-jar.xml file. <persistence-type> element value is ________________ | Bean or Container
Which of the following statements are true for <jsp:usebean>. Select the two correct answers | a. The id attribute must be defined for <jsp:usebean> b. The <jsp:usebean> must include either type or class attribute or both
When a web server responds to a request from a browser or other Web client the response typically consists of. (choose one) | A status line, some response headers, a blank line, and the document.
Message-driven beans are clsses that implement 02 interfaces: | a. Javax.ejb.messageDrivenBean b. Javax.jms.MessagerListener
Which of these is a correct example of specifying a listener element resented by MyClass class? Assume myServlet element is defined correctly. Select the one correct answer | a. <listener><listerner-class>MyClass</listener-class></listener>
A bean with a property color is loaded using the following statement <jsp:usebean id=�fruit� class=�Fruit�/> What happen when the following statement is executes. Select the one correct answer. <jsp:setPropety name=�fruit� property=��/> | a. All the properties of the fruit bean are assignet the values of input parameters of the JSP page that have the same name.
A ______________ session bean is a bean that holds conversations that span a single method call | Stateless
The top three value of EJB are (choose 3) | a. It is agreed upon by the industry. b. Portability is easier c. Rapid application development
Which of the HTTP methods below is not considered to be �oeidempotent�? (Choose one.) | a. POST
Which of the HTTP methods below are likely to change state on the web server? (Choose three.) | a. DELETE b. POST c. PUT
Which of the following are valid servlet methods that match up with HTTP methods? (Choose four.) | a. doGet() b. doPost() c. doOptions() d. doHead()
What is the likely effect of calling a servlet with the POST HTTP method if that servlet does not have a doPost() method? (Choose one.) | a. 405 response code: SC_METHOD_NOT_ALLOWED.
What is the likely effect of calling a servlet with the HEAD HTTP method if that servlet does not have a doHead() method? (Choose one.) | a. 200 response code: SC_OK
What will be the result of pressing the submit button in the following HTML form? (Choose two.) | a. A request is sent with the HTTP method GET. b. The parameters fullName and sbmButton are passed to the web server in the request URL.
Consider the following form and servlet code. Assuming the user changes none of the default settings and presses submit, what will the servlet output in the response? (Choose one.) <form action="PrintParams?param1=First" method="post"> <input type="hidden" name="param1" value="First" /> <input type="text" name="param1" value="Second" /> <input type="radio" name="param1" value="Third" /> <input type="submit" /> </form> protected void doPost HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.write("<html>\n<head>\n<title>Print Parameters</title>\n</head>\n<body>"); String[] param1 = request.getParameterValues("param1"); for (int i = 0; i < param1.length; i++) out.write(param1[i] + ":"); } out.write("\n</body>\n</html>"); out.close(); } | a. First:First:Second
What is the maximum number of parameter values that can be forwarded to the servlet from the following HTML form? (Choose one.) <html> <body> <h1>Chapter 1 Question 9</h1> <form action="ParamsServlet" method="get"> <select name="Languages" size="3" multiple> <option value="JAVA" selected>Java</option> <option value="CSHARP">C#</option> <option value="C" selected>C</option> <option value="CPLUSPLUS">C++</option> <option value="PASCAL">Pascal</option> <option value="ADA">Ada</option> </select> <input type="submit" name="button" /> </form> </body> </html> | a. 7
What request header must be set for parameter data to be decoded from a form? (Choose one.) | a. Content-Type: application /x-www-form-urlencoded
Which of the following are likely to found as request header fields? (Choose three.) | a. Accept b. Accept-Language c. From
What is the most likely outcome of running the following servlet code? (Choose one.) long date = request.getDateHeader("Host"); response.setContentType("text/plain"); response.getWriter().write("" + date); | a. IllegalArgumentException
What is the likely outcome of attempting to run the following servlet code? String[] values = request.getHeaders("BogusHeader"); response.setContentType("text/plain"); response.getWriter().write(values[0]); | a. Won’t run: 2 compilation errors
What is the likely outcome of attempting to compile and run the following servlet code, assuming there is one cookie attached to the incoming request? 11 Cookie[] cookies = request.getCookies(); 12 Cookie cookie1 = cookies[0]; 13 response.setContentType("text/plain"); 14 String attributes = cookie1.getName(); 15 attributes += cookie1.getValue(); 16 attributes += cookie1.getDomain(); 17 attributes += cookie1.getPath(); 18 response.getWriter().write(attributes); | a. Output to the response including at least the name and value
Under what circumstances can the HttpServletRequest.getHeaders(String name) method return null? (Choose one.) | a. If the container disallows access to the header information
Which of the following methods can be used to add cookies to a servlet response? (Choose two.) | a. HttpServletResponse.addCookie(Cookie cookie) b. HttpServletResponse.addHeader(String name, String value)
What is the outcome of running the following servlet code? (Choose two.) public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain;charset-UTF-8"); PrintWriter out = response.getWriter(); out.flush(); out.close(); System.out.println(response.isCommitted()); response.setContentType("illegal/value"); } | a. A blank page is returned to the client b. �oetrue� is output on the server’s console.
What will be the outcome of executing the following code? (Choose one.) public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); response.setContentLength(4); PrintWriter out = response.getWriter(); out.write("What will be the response? "); out.write("" + response.isCommitted());} | a.�oeWhat� is returned to the client.
In the code fragments below, consider that �oeresponse� is an instance of HttpServletResponse.) (Choose two.) | a. response.sendRedirect("index.jsp"); b. response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
Identify statements that are always true about threads running through the service() method of a servlet with the following class declaration. (Choose two.) | a. There could be anything from zero to many threads running through the service() method during the time the servlet is loaded. b. D. If the init() method for the servlet hasn’t run, no threads have yet been able to run through the service() method.
Under which of the following circumstances are servlets most likely to be instantiated? (Choose four.) | a. During web application startup b. On a client first requesting the servlet c. At some arbitrary point in the web application or application server lifetime d. After the time specified on an UnavailableException has expired
Which of the following are true statements about servlet availability? (Choose two.) | a. If a servlet is removed from service, then any requests to the servlet should result in an HTTP 404 (SC_NOT_FOUND) error. b. If a servlet is deemed temporarily unavailable; a container may return an HTTP 503 (SC_SERVICE_UNAVAILABLE) message on receiving requests to the servlet during its time of unavailability.
Under what circumstances will a servlet instance’s destroy() method never be called? (Choose two.) | a. When init() has not run to completion successfully b. After destroy() has already been called
Given the following servlet code, identify the outputs that could not or should not occur during the lifetime of the web application housing the servlet. | a. destroy:service: b. init:service:init:service:
Which of the following directories are legal locations for the deployment descriptor file? Note that all paths are shown as from the root of the machine or drive. (Choose two.) | a. / WEB-INF b. /appserverInstallDirectory/webapps/webappName/ WEB-INF
What would be the best directory in which to store a supporting JAR fi le for a web application? Note that in the list below, all directories begin from the context root. (Choose one.) | / WEB-INF/lib
What’s the likely outcome of a user entering the following URL in her browser? You can assume that index.html does exist in /WEB-INF/html, where /WEB-INF/html is a directory off the context root, and that the server, port, and context details are specified correctly. (Choose one.) | An HTTP response code of 404 returned to indicate that the requested resource has not been found.
Identify which of the following are true statements about web applications. (Choose three.) | Server-side code has access to all resources in the web application. Clients of web applications can’t directly access resources in / WEB-INF/tld. A good place to keep a .tld (tag library fi le) is directly in the / WEB-INF directory See the extract from web.xml below: <servlet-mapping> <servlet-name>ServletA</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletB</servlet-name> <url-pattern>/bservlet.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletC</servlet-name> <url-pattern>*.servletC</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>ServletD</servlet-name> <url-pattern>/dservlet/*</url-pattern> </servlet-mapping> Given that a user enters the following into her browser, which (if any) of the mapped servlets will execute? (Choose one.) | ServletA
What is the parent tag for <welcome-file-list>? (Choose one.) | <web-app>
Which of the following are true statements about the deployment descriptor for a web application? (Choose two.) | <welcome-file> is a child element of <welcome-file-list>. At least one element must be present.
What of the following represents a correct declaration of a servlet in the deployment descriptor? (Choose one.) | <servlet> <description>MyServlet</description> <servlet-name>MyServlet</servlet-name> <servlet-class>MyServlet</servlet-class> </servlet>
Given five servlets with <load-on-startup> value set as follows, and declared in the following order in the deployment descriptor, ¦ ServletA: 1 ¦ ServletB: 0 ¦ ServletC: 1 ¦ ServletD: 1 ¦ ServletE: no value set for <load-on-startup> Identify true statements from the list below. (Choose one.) | ServletB will load before ServletC.
What will be the outcome of compiling and deploying the servlet code below? (You can assume that correct import statements are provided and that the servlet lives in the default package. Line numbers are for ease of reference and are not part of the code.) 11 public class NameServlet extends HttpServlet { 12 protected void doGet(HttpServletRequest request, 13 HttpServletResponse response) { 14 out.write(getServletName()); 15 } 16 } | Will not compile for some other reason
Assume that there is a fi le called secure.txt, located at / WEB-INF/securefi les, whose contents are �oePassword=WebCert.� What statements are false about the result of compiling and running the following code? 11 public class CodeTestServlet extends HttpServlet { 12 protected void doGet(HttpServletRequest request, 13 HttpServletResponse response) throws IOException { 14 ServletContext sc = getServletContext(); 15 InputStream is = sc.getResourceAsStream("/WEB-" + 16 "INF/securefiles/secure.txt"); 17 BufferedReader br = new BufferedReader(new InputStreamReader(is)); 18 System.out.println(br.readLine());19 }20 } | A, B, C, and D above.
Given the following deployment descriptor: <web-app> <servlet> <servlet-name>InitParams</servlet-name> <servlet-class>com.osborne.c02.InitParamsServlet</servlet-class> <init-param> <param-name>initParm</param-name> <param-value>question14</param-value> </init-param> </servlet> </web-app> What is the outcome of running the following servlet? (Choose one.) | �oeInitialization Parameter is: null� returned to the requester
Which of the following methods derive from the ServletConfig interface? (Choose three.) | ServletContext getServletContext(). String getInitParameter(String name) . String getServletName()
Which of the following is a valid way to set up a mime mapping in the deployment descriptor? (Choose one.) | <mime-mapping> <extension>txt</extension> <mime-type>text/plain</mime-type> <mime-mapping>
Which of the following servlet methods can return null? (Choose one.) | getInitParameter(String name)
Identify correct statements about the META-INF directory from the list below. (Choose three.) | META-INF is a suitable location for storing digital certifi cates. The MANIFEST.MF file is found in the META-INF directory. META-INF is not directly accessible to clients.
Identify correct statements about WAR files from the list below. (Choose three.) | A META-INF directory will be present in the WAR file. A WEB-INF directory will be present in the WAR file. A WAR file is in ZIP file format.
Consider the following list of files in a web application, where myApp is the context path: /devDir/myapp/index.jsp /devDir/myapp/WEB-INF/web.xml /devDir/myapp/WEB-INF/classes/webcert/ch02/SomeServlet.class Which of the following sets of instructions will build a correctly formed web archive file?(Choose one.) | Change directory to /devDir/myApp; execute jar cvf someapp.war *.*
What is the result of loading the web-app with the following deployment descriptor and attempting to execute the following servlet? (Choose two.) <web-app> <context-param><paramname>author</paramname> <paramvalue>Elmore Leonard</paramvalue> </context-param> </web-app> public class ContextInitParms extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.write("<HTML><HEAD></HEAD><BODY>"); ServletContext sc = getServletContext(); out.write(sc.getInitParameter("auther")); out.close();}} | An application failure occurs. A 404 error occurs in the browser
What results from a call to the getInitParameterNames() method on ServletContext when there are no context parameters set up in the deployment descriptor? (Choose two.) | An empty Enumeration object is returned. No exceptions are thrown.
Identify true statements about context parameters from the list below. (Choose one.) | None of the above.
Given a servlet containing the following code, what is the outcome of attempting to compile and run the servlet? (Choose one.) | The servlet won’t compile
What is the likely result from attempting to compile and execute the following servlet code? (Choose one.) HttpSession session = getSession(); String s = session.getAttribute("javax.servlet.session.tempdir"); | Won’t compile for more than one reason.
Identify true statements from the list below. (Choose two.) | You cannot remove request parameters. Attributes can be set by the web container or by application code.
What is result of attempting to run the following code? (Choose one.) public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("a", "request"); System.out.print(request.getAttribute("a"));request.setAttribute("a", "2nd request"); System.out.print(","); System.out.print(request.getAttribute("a")); request.removeAttribute("a"); request.removeAttribute("a"); System.out.print(","); Object o = request.getAttribute("a"); System.out.print(o);} | �oerequest, 2nd request, null� written to standard output
From the following list, what is a probable outcome from a call to the ServletContext.getAttributeNames() method? (Choose one.) | A nonempty Enumeration is returned.
Identify true statements about scope from the following list. (Choose two.) | Session scope can span JVMs. Requests can span web apps
What is the outcome of executing ServletA? You can assume that (1) ServletB has a mapping of�oe/ServletB� and a name of �oeServletB,� and (2) imports have been omitted from the code for breity; the code will compile successfully. (Choose one.) public class ServletA extends HttpServlet { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { RequestDispatcher rd = getServletContext().getNamedDispatcher( "ServletB"); rd.forward(req, resp);}} public class ServletB { public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String attr = (String) req.getAttribute("javax.servlet.forward.servlet_path"); PrintWriter out = resp.getWriter(); out.write("Attribute value: " + attr); }} | �oeAttribute value: null� output to the web page
Identify which of the following are names of special attributes associated with the dispatching mechanism. (Choose two.) | javax.servlet.include.servlet_path. javax.servlet.include.path_info
What are possible outcomes from executing the doGet method in ServletC below? (Choose two.) public class ServletC extends HttpServlet {public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { RequestDispatcher rd = getServletContext().getRequestDispatcher("ServletB");rd.forward(req, resp);}} | HTTP 500 error (error in 500s). Some other exception.
What is the web page output from executing ServletD with the URL below? (Choose one.) http://localhost:8080/myapp/ServletD?fruit=orange public class ServletD extends HttpServlet {public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { RequestDispatcher rd = getServletContext().getRequestDispatcher("/ServletE?fruit=pear");rd.forward(req, resp);}}public class ServletE extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {response.setContentType("text/plain");PrintWriter out = response.getWriter();String[] valueArray = request.getParameterValues("fruit");for (int i = 0; i < valueArray.length; i++) {if (i > 0) {out.write(", ");}out.write(valueArray[i]);}String queryString = (String) request.getAttribute("javax.servlet.forward.query_string");int pos = queryString.indexOf("=") + 1;String values = queryString.substring(pos); out.write(", " + values);}} | pear, orange, orange
ServletA forwards to ServletB, which includes Servlet C, which forwards to ServletD, which includes ServletE. When ServletA is requested, which servlets might contribute to the final response? (Choose one.) | ServletD and ServletE
Identify true statements about fi lters. (Choose one.) | You cannot work directly with the request object that is passed as a parameter to the filter.
Which of the following is a legal filter mapping declaration in the deployment descriptor? (Choose one.) | <filter-mapping> <filter-name>MicroPaymentFilter</filter-name> <servlet-name>MicroPaymentServlet</servlet-name> <dispatcher>REQUEST</dispatcher> </filter-mapping>
From the available options, what is the likely outcome from running the code below? (Choose one.) protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher dispatcher =getServletContext().getNamedDispatcher("/ServletB"); dispatcher.forward(request, response);} | NullPointerException.
Given the following deployment descriptor, identify the sequence of fi lters that execute on a direct client request for ServletA. (Choose one.) <filter-mapping> <filter-name>LogFilter</filter-name> <servlet-name>ServletA</servlet-name> </filter-mapping> <filter-mapping> <filter-name>AuditFilter</filter-name><url-pattern>/ServletA</url-pattern> <dispatcher>FORWARD</dispatcher></filter-mapping><filter-mapping><filter-name>EncryptionFilter</filter-name><url-pattern>/*</url-pattern></filter-mapping><servlet-mapping><servlet-name>ServletA</servlet-name><url-pattern>/ServletA</url-pattern></servlet-mapping> | EncryptionFilter, LogFilter
What is the outcome of attempting to compile, deploy, and run the following servlet code? Line numbers are for reference only and should not be considered part of the code. (Choose one.) 10 import java.io.*;11 import javax.servlet.*;12 import javax.servlet.http.*;13 public class Question2 extends HttpServlet {14 protected void doGet(ServletRequest request,15 ServletResponse response) throws ServletException, IOException {16 HttpSession session = request.getSession(false);17 session.invalidate();18 session.setAttribute("illegal", "exception thrown"");19 }20 } | Won’t compile
Identify the two equivalent method calls in the list below. (Choose two.) | HttpServletRequest.getSession(). HttpServletRequest.getSession(true)
Identify true statements about sessions from the list below. (Choose two.) | Sessions can be cloned across JVMs. Sessions can be set to never time out.
Which of the following mechanisms will guarantee that every session in a web application will expire after 1 minute? You can assume that for each answer below, this is the only session timeout mechanism in force for the web application. (Choose two.) | In the deployment descriptor:<session-config><session-timeout>1</session-timeout></session-config> b. In the doFilter() method of a fi lter that has the following <url-pattern> mapping in the deployment descriptor: �oe/.� request is an instance of HttpServletRequest, cast from the ServletRequest parameter passed to the method. HttpSession session = request.getSession();session.setMaxInactiveInterval(60);
Identify the default mechanism for session management from the list below. (Choose one.) | Cookies
Identify correct statements about session management from the list below. (Choose two.) | The unique identifi er for a session may be passed back and forward through a name/value. pair in the URL. The name is jsessionid.
Session management is usually dependent on a hidden form field called JSessionId. | The rules for rewriting URLs for links may be different from those for rewriting URLs for redirection.
Given the following servlet code called with this URL -http://127.0.0.1:8080/ examp0402/Q9-and also given that URL rewriting is the session mechanism in force, identify the likely output from the servlet from the choices below. (Choose one.) PrintWriter out = response.getWriter();response.setContentType("text/html");out.write("<HTML><HEAD>");out.write("<TITLE>Encoding URLs</TITLE>");out.write("</HEAD><BODY>");HttpSession session = request.getSession();out.write("\n<P>Session id is <B>"+ session.getId() + "</B>.</P>");String URL1 = response.encodeURL("Q9");String URL2 = response.encodeURL("http://127.0.0.1:8080/examp0401/Q1");out.write("\n<P>URL1: " + URL1 + "</P>");out.write("\n<P>URL2: " + URL2 + "</P>");out.write("</BODY></HTML>"); | Output: Session ID is 4EDF861942E3539B1F3C101B71636C1A.URL1: Q9;jsessionid=4EDF861942E3539B1F3C101B71636C1A. URL2: http://127.0.0.1:8080/examp0401/Q1
Which of the following statements contain accurate advice for web developers? (Choose two.) | Because the client determines whether cookies are permitted or not, it’s a good idea always to encode URLs as a fallback session mechanism. Static pages in your web application can disrupt session management. Request and Context Listeners
Identify actions that won’t fi x a potential problem in the following ServletRequestListener code.(Choose two.)01 public void requestDestroyed(ServletRequestEvent reqEvent) {02 HttpServletRequest request = (HttpServletRequest) 03 reqEvent.getServletRequest(); 04 HttpSession session = request.getSession(); 05 session.setAttribute("name","value");06 } | Ensure that any servlet in your web application obtains a session. Take no action, for the code will work in all circumstances.
What is the outcome of attempting to compile and run the servlet code below? (Choose one.) import java.io.*; import javax.servlet.*;import javax.servlet.http.*;public class Question12 extends HttpServlet {protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException {ServletContext context = getServletContext();context.addAttribute("mutable", "firstvalue");context.replaceAttribute("mutable", "secondvalue");context.removeAttribute("mutable");context.removeAttribute("mutable");}} | None of the above.
Identify true statements about listener interfaces and related classes from the list below. (Choose three.) | It is possible to add context attributes in the contextDestroyed() method. You can access the current session from methods in classes implementing the Servlet RequestListener interface. It is unwise to change request attributes in the attributeReplaced() method of a class implementing the ServletRequestAttributeListener interface
Identify the number and nature of the errors in the code below, which is taken from a class implementing the ServletRequestAttributeListener interface. (Choose one.)01 public void attributeAdded(ServletRequestAttributeEvent event) {02 HttpServletRequest request = event.getServletRequest();03 Object o = event.getSource();04 System.out.println("Source of event is: "05 + o.getClass().getName());06 String name = event.getName();07 String value = event.getValue();08 System.out.println("In ServletRequestAttributeListener."09 + "attributeAdded() with name: "10 + name + ", value; " + value);11 } | Two compilation errors
If a request attribute has been replaced, which of the following techniques will not obtain the current (new) value of the attribute? (Choose two.) | Use the ServletRequestAttributeEvent.getValue() method anywhere in the attributeReplaced() method of a class implementing ServletRequestAttributeListener. Use the ServletRequestAttributeEvent.getValue() method anywhere in the attributeUpdated() method of a class implementing ServletRequestAttributeListener
The code below shows code for the class MySessionAttribute (Listing A). An instance of this class is attached to an HttpSession (Listing B). From the list below, pick out the things that will happen when this session is migrated from a source JVM to a target JVM. (Choose four.) LISTING A import java.io.*;import javax.servlet.http.*;public class MySessionAttribute implements HttpSessionActivationListener, Serializable { private static String data; public String getData() { return data; } public void setData(String newData) { data = newData;}public void sessionWillPassivate(HttpSessionEvent arg0) {System.out.println(data);}public void sessionDidActivate(HttpSessionEvent arg0) {System.out.println(data);}} ..... | sessionWillPassivate() method called in the source JVM. sessionDidActivate() method called in the target JVM. �oeMy data� written to the source JVM’s web server console. �oeMy data� not written to the source JVM’s web server console
Pick out true statements from the list below. (Choose two.) | More than one session listener interface may take effect from the same deployment descriptor declaration. An HttpSessionListener’s sessionDestroyed() method will be called as a result of a client refusing to join a session.
A web application houses an HttpSessionAttributeListener and an object (SessionAttrObject) that implements HttpSessionBindingListener. Pick out the correct sequence of listener method calls that follows from executing l the servlet code below inside this web application.(Choose one.)import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class Question20 extends HttpServlet {protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {HttpSession session = request.getSession();session.invalidate();HttpSession newSession = request.getSession();SessionAttrObject boundObject = new SessionAttrObject("value");newSession.setAttribute("name", boundObject);newSession.setAttribute("name", "value");newSession.setAttribute("name", null);} } | valueBound(), attributeAdded(), valueUnbound(), attributeReplaced(),attributeRemoved()
Which security mechanism proves that data has not been tampered with during its transit through the network? (Choose one.) | Data integrity
Which security mechanism limits access to the availability of resources to permitted groups of users or programs? (Choose one.) | Authorization
Which of the following deployment descriptor elements play some part in the authentication process? (Choose three.) | <login-config>. <auth-method>. <form-error-page>
In a custom security environment, for which security mechanisms would a fi lter be incapable of playing any useful part? (Choose one.) | None of the above
Review the following scenario; then identify which security mechanisms would be important to fulfill the requirement. (Choose two.) | Authorization. Authentication
Identify which choices in the list below show immediate subelements for <securityconstraint> in the correct order. (Choose two.) | <web-resource-collection>,<auth-constraint>,<user-data-constraint>. <web-resource-collection>,<auth-constraint>
Identify valid confi gurations for the <transport-guarantee> element in the deployment descriptor. (Choose four.) | <transport-guarantee>CONFIDENTIAL</transport-guarantee>b. Absent altogether from the deployment descriptor c. <transport-guarantee>NONE</transport-guarantee> d. <transport-guarantee>INTEGRAL</transport-guarantee>
Given the following incomplete extract from a deployment descriptor, what are possible ways of accessing the protected resource named TheCheckedServlet? (Choose three.)<security-constraint><web-resource-collection><web-resource-name>TheCheckedServlet</web-resource-name><url-pattern>/CheckedServlet</url-pattern></web-resource-collection><auth-constraint /></security-constraint><security-constraint><web-resource-collection><web-resource-name>TheCheckedServlet</web-resource-name><url-pattern>/CheckedServlet</url-pattern><http-method>GET</http-method></web-resource-collection><auth-constraint><role-name>bigwig</role-name></auth-constraint></security-constraint> | Via another URL pattern (if one is set up elsewhere within the deployment descriptor). Via RequestDispatcher.include(). Via RequestDispatcher.forward().
Which of the following might a web server consider important in ensuring a transport guarantee of CONFIDENTIAL? (Choose four.) | Server-side digital certifi cates. Symmetric keys. Asymmetric (public/private keys). SSL
The following web page is defined as the custom form login page for authentication. Assuming that you have attempted to access a protected resource and been redirected to this web page, what is the result of fi lling in the user name and password fi elds and pressingsubmit? (Choose one.)<html><head><title>Login Form</title></head><body><form action="jsecuritycheck" method="POST"><br />Name: <input type="text" name="jusername" /><br />Password: <input type="password" name="jpassword" /><br /><input type="submit" value="Log In" /></form></body></html> | The page is redisplayed.
What is the result of the following login configuration? (Choose one.) <login-config><auth-method>FORM</auth-method><form-login-config><form-login-page>login.html</form-login-page><form-error-page>error.html</form-error-page></form-login-config></login-config> | Application fails to start.
Which of the following sub elements might you expect to fi nd in the <login-config> for BASIC authorization? (Choose two.) | <auth-method>. <realm-name>
Which of the following sub elements would you not expect to fi nd in the <login-config> for CLIENT-CERT authorization? (Choose four.) | <auth-constraint>. <role-name>. <form-login-page>. <realm-name>
What will be the most likely outcome of attempting to access the following JSP for the second time? (Choose one.) <%@ page language="java" %> <%@ page import="java.util.*" %><html><head><title>Chapter 6 Question 1</title></head><body><h1>Chapter 6 Question 1</h1><%!public void jspInit() {System.out.println("First half of jspInit()");%><%> new Date() %><%!System.out.println("Second half of jspInit()");}%></body></html> | Web page returned showing a heading and the current date
What is output to the web page on the second access to the same instance of the following JSP?(Choose one.)<%@ page language="java" %><html><head><title>Chapter 6 Question 2</title></head><body><h1>Chapter 6 Question 2</h1><%! int x = 0; %><%!public void jspInit() {System.out.println(x++);}%><%= x++ %><% System.out.println(x); %><% jspInit(); %></body></html> | 3
For what reason does the following JSP fail to translate and compile? (Choose one.) <%@ page language="java" %><html><head><title>Chapter 6 Question 3</title></head><body><h1>Chapter 6 Question 3</h1><%! int x; %><%!public void jspDestroy() {System.out.println("self-destructing");} %><%!public void jspInit() {System.out.println(<%= x %>);}%></body></html> | Expression embedded in declaration.
Which of the following are true statements about the JavaServer Page life cycle? (Choose two.) | The _jspService() method is called from the generated servlet’s service() method. All servlet methods are accessible from the jspInit() method
What is the consequence of attempting to access the following JSP page? (Choose two.)<%@ page language="java" %><html><head><title>Chapter 6 Question 5</title></head><body><h1>Chapter 6 Question 5</h1><%!public void _jspService(HttpServletRequest request,HttpServletResponse response) {out.write("A");} %><% out.write("B"); %></body></html> | Cannot resolve symbol compilation error. Duplicate method compilation error.
What is the result of attempting to access the following JSP page? (Choose one.) <html><head><title>Chapter 6 Question 6</title></head><body><h1>Chapter 6 Question 6</h1><%! public String methodA() {return methodB();}%><%! public String methodB() {return methodC();}%><% public String methodC() {return "Question 6 Text";}%><h2><%= methodA() %></h2></body></html> | A translation error occurs.
What true statements can you make about the following JSP page source? The line numbers are for reference only and should not be considered part of the source.(Choose two.)01 <%@ page import="java.io.*" %>02 <html>03 <head><title>Chapter 6 Question 8</title></head> 04 <body> 05 <% 06 PrintWriter out = response.getWriter(); 07 out.write("P"); 08 %> 09 <% out.write("Q"); %> 10 </body> 11 </html> | In JSP technology, it’s a bad idea to get hold of the PrintWriter directly from the response. The page has a compilation error for other reasons
Which of the following are false statements to make about JSP scripting elements?(Choose three.) | It is legal to embed a <%--style comment inside another comment. It is legal to embed an expression inside a declaration. It is legal to embed an expression inside a directive
What is the result of attempting to access the following JSP page source? (Choose one.) <% <%-- for (int i = 0; i < 10; i++) {<%-- if(i==3) System.out.println("i is 3!");--%>System.out.println("i squared is " + i * i);} %> --%> | The JSP page would compile if one of the percent (%) signs were removed
Which of the following constitute valid ways of importing Java classes into JSP page source? (Choose two.) | <%@ page import='java.util.*, java.io.PrintStream' b. <%@page import = " java.util.* "%>
What is the outcome of accessing the fi rst JSP page, includer12.jsp, shown below?(Choose one.)<%-- file includer12.jsp begins here --%><% for (int i = 0; i < 10; i ++) { %><%@ include file="included12.jsp" %><% } %><%-- End of file includer12.jsp --%><%-- Beginning of file included12.jsp --%><html><head><title>Chapter 6 Question 12</title></head><body><h1>Chapter 6 Question 12</h1>For the <%=i%>th time<br /></body></html><%-- End of file included12.jsp --%> | An ill-formed HTML page will be the output
What statements are true about the following two JSP page sources, given the intention of always requesting includer13.jsp? (Choose two.) <%-- file includer13.jsp begins here --%> <%@ page import="java.util.*" contentType="text/html" session="true"%> <html> <head><title>Chapter 6 Question 13</title></head><body><h1>Chapter 6 Question 13</h1><%ArrayList al = new ArrayList();al.add("Jack Russell");al.add("Labrador");al.add("Great Dane");%><%@ include file="included13.jsp" %></body></html><%-- file includer13.jsp ends here --%><%-- file included13.jsp begins here --%><%@ page import="java.util.*" contentType="text/html" %><table><%for (int i = 0; i < al.size(); i++) {%><tr><td><%= al.get(i) %></td></tr><%}%></table><%-- file included13.jsp ends here --%> | Removing the Session attribute from includer13.jsp will make no difference to the generated servlet code. The order of the import and contentType attributes in both JSP page sources is immaterial.
Which of the following are invalid directives? (Choose three.) | <%@page isELignored = �oefalse� %> b. <%@ page session=the�oe/’ is okay true’ %> c. <%@include uri=�oeheader.jsp� %>
Given the beginning of the JSP page source below, which set of lines should be used to complete the JSP page source in order to print out all the song lyrics? (Choose one.)<%! static String[] suedeShoes = new String[4];static { suedeShoes[0] = "One for the Money,";suedeShoes[1] = "Two for the Show,";suedeShoes[2] = "Three to Get Ready,";suedeShoes[3] = "And Go, Cat, Go!";} %><% pageContext.setAttribute("line1", suedeShoes[0]);request.setAttribute("line2", suedeShoes[1]);session.setAttribute("line3", suedeShoes[2]);config.getServletContext().setAttribute("line4", suedeShoes[3]);%><%@ page contentType="text/plain" info="Blue Suede Shoes" session="false" %><%for (int i = 0; i < suedeShoes.length; i++) {String songLine = (String) pageContext.findAttribute("line" + (i + 1));%><%= songLine %><%}%> | <%@ page contentType="text/plain" info="Blue Suede Shoes" session="true" %><%for (int i = 0; i < suedeShoes.length; i++) {String songLine = (String) pageContext.findAttribute("line" + (i + 1));%><%= songLine %><%}%>
Which of the following techniques is likely to return an initialization parameter for a JSP page? (Choose two.) | <% String s = getInitParameter(�oemyParm�); %> b. <%= config.getInitParameter(�oemyParm�); %>
What is the result of requesting errorProvoker.jsp for the fi rst time? Assume that neither of the JSP pages below has yet been translated. (Choose one.)<%--Beginning of errorProvoker.jsp page source --%><%@ page errorPage="/errorDisplayer.jsp" %><% request.setAttribute("divisor", new Integer(0)); %><html><head><% int i = ((Integer) request.getAttribute("divisor")).intValue(); %><title>Page Which Terminates In Error</title></head><body><%= 1.0 / i %></body></html><%-- End of errorProvoker.jsp page source --%><%-- Beginning of errorDisplayer.jsp page source --%><%@ page isErrorPage="true" %><%@ page import="java.io.*" %><html><head><title>Divide by Zero Error</title></head><body><h1>Don't divide by zero!</h1><pre><% exception.printStackTrace(new PrintWriter(out)); %></pre></body></html><%-- End of errorDisplayer.jsp page source --%> | errorDisplayer.jsp will not be translated. errorProvoker.jsp displays output.
Which of the following are false statements about implicit objects and scope? (Choose four.) | out is of type java.io.PrintWriter. config can be used to return context initialization parameters. application can’t be used to access other web application resources.
What is the result of attempting to access attributeFinder.jsp below, typing text into the input field, and pressing the submit button? (Choose one.)<%-- Beginning of attributeFinder.jsp page source --%><%@ include file="fieldSetter.jsp" %><html><head><title>Echo Input</title></head><body><h5>Type in the field below and press the button to echoinput...</h5><form><input type="text" name="<%= session.getAttribute("echoFieldName")%>" /><input type="submit" /></form><h3>Echoed Text: <%= request.getAttribute("echoInput") %></h3></body></html><%-- End of attributeFinder.jsp page source --%><%-- Beginning of fieldSetter.jsp page source --%><% session.setAttribute("echoFieldName", "echoInput"); %><%-- End of fieldSetter.jsp page source --%> | null is displayed for the echoed text.
Which of the following are potentially legal lines of JSP source? (Choose two.) | <jsp:useBean id="beanName1" class="a.b.MyBean" type="a.b.MyInterface" /> b. <% String myValue = "myValue"; %> <jsp:setProperty name="beanName1" property="soleProp" value="<%=myValue%>" />
Which of the following are false statements about <jsp:useBean> standard action attributes? (Choose three.) | If the type attribute is used, the class attribute must be present. If both are used, class and type attributes must have different values. If both are used, class and type attributes must have the same value.
Given a NameBean with a �oename� property and an AddressBean with an �oeaddress� property,what happens when the following JSP is requested with the following URL? (Choose one.)Calling URL:http://localhost:8080/examp0701/Question4.jsp?name=David%20Bridgewater&address=Leeds%20UKJSP page source:<jsp:useBean id="name" class="webcert.ch07.examp0701.NameBean" /><jsp:useBean id="address" class="webcert.ch07.examp0701.AddressBean" /><jsp:setProperty name="name" property="name" /><jsp:setProperty name="address" param="*" /><jsp:getProperty name="name" property="name" /><jsp:getProperty name="address" property="address" /> | A translation time error occurs
What is the outcome of making the HTTP GET request shown to params.jsp (source follows)?(Choose one.) The HTTP request is in this form: http://localhost:8080/examp0702/params.jsp?X=1&Y=2&Z=3 Source of params.jsp: <jsp:include page="included.jsp"> <jsp:param name="X" value="4" /><jsp:param name="X" value="5" /><jsp:param name="Y" value="6" /></jsp:include>${param.X}<%=request.getParameter("Y")%>Source of included.jsp:${param.X} ${param.Y}<% String[] x = request.getParameterValues("X");for (int i = 0; i < x.length; i++) {out.write(x[i]);}%> | 4 6 451 1 2
Which of the following are helpful statements about the include standard action and the include directive? (Choose three.) | The include standard action is useful when soft-coding the page to include. Given the same page to include, the include directive may be more effi cient than the include standard action at request time. The body of the include standard action can infl uence existing request parameters
What will be the result of requesting the JSP page represented by the following source? Assume that �oeforwardedTo.jsp� is an empty file. (Choose one.)<%@ page import="java.util.*,java.text.*" %><%! private String returnTimeStamp(PageContext pageContext) {DateFormat df = DateFormat.getDateTimeInstance();String s = df.format(new Date());pageContext.setAttribute("timestamp", s);return s;} %><jsp:forward page="forwardedTo.jsp" /><%=returnTimeStamp(pageContext)%><%System.out.println(pageContext.getAttribute("timestamp"));%> | None of the above.
What is the outcome of making the HTTP GET request shown to params.jsp (source follows)?(Choose one.)The HTTP request is in this form:http://localhost:8080/examp0702/params.jsp?X=1&Y=2&Z=3Source of params.jsp:<jsp:forward page="included.jsp"><jsp:param name="X" value="4" /><jsp:param name="X" value="5" /><jsp:param name="Y" value="6" /><jsp:forward/>${param.X}<%=request.getParameter("Y")%>Source of included.jsp:${param.X}${param.Y}<% String[] x = request.getParameterValues("X");for (int i = 0; i < x.length; i++) {out.write(x[i]);}%> | None of the above
What is the outcome of accessing the following page, defi ned as a JSP document in a web application? The line numbers are for reference only and should not be considered part of the JSP page source. (Choose one.)01 <html xmlns:jsp="http://java.sun.com/JSP/Page">02 <jsp:directive.page contentType="text/html" />03 <jsp:declaration>04 public int squared(int value) {05 return value * value;06 }07 </jsp:declaration>08 <jsp:scriptlet>09 int value = Integer.parseInt10 (request.getParameter("number"));11 int squared = squared(value);12 out.write(value + " squared is " + squared);13 if (squared < 100) {14 out.write("; try a bigger number.");15 }16 </jsp:scriptlet>17 </html> | Translation error at line 13
Which of the following techniques will cause JSP page source to be treated as a JSP document by the JSP container? (Choose two.) | Using a .jspx extension with a version 2.4 deployment descriptor. Using <jsp:root> as the root element of your source
Which of the following tags will successfully complete the following JSP page extract, at the points marked <jsp:???> and </jsp:???> ? (Choose one.)<html xmlns:jsp="http://java.sun.com/JSP/Page" ><jsp:directive.page contentType="text/html" /><head><title>Question 15</title></head><jsp:???><![CDATA[<img src="]]></jsp:???><jsp:expression>session.getAttribute("theImage")</jsp:expression><jsp:???><![CDATA[" />]]></jsp:???></html> | <jsp:text> and </jsp:text>
Which of the following are implicit variables in EL? (Choose two.) | param. paramValues
Which of the following EL expressions will return a <servlet-name> associated with the JSP executing the expression? (Choose one.) | ${pageContext.servletConfig.servletName}
Which of the following XML fragments, if placed below the root element in the deployment descriptor, will deactivate the scripting language for all fi les in the web application with a .jsp extension? (Choose one.) | <jsp-config><jsp-property-group><url-pattern>*.jsp</url-pattern><scripting-invalid>true</scripting-invalid></jsp-property-group></jsp-config>
Which of the following deployment descriptors will successfully and legally deactivate Expression Language for an entire web application? (Choose two) | a. <?xml version="1.0" ?><!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN""http://java.sun.com/dtd/web-app_2_3.dtd"><web-app></web-app> b. <?xml version="1.0" ?><web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"><jsp-config><jsp-property-group><url-pattern>/*</url-pattern><el-ignored>true</el-ignored></jsp-property-group></jsp-config></web-app>
From the following use of the tag <mytags:convert>, what statements must be true about its setup and use? You can assume that the tag translates and executes correctly. (Choose three.) <mytags:convert currency="${param.cur}"><%= amount %></mytags:convert> | The taglib declaration has a prefi x of �oemytags.�. In the TLD, the tag’s body content element has a value of JSP. In the TLD, the tag’s currency attribute has the rtexprvalue element set to true.
Which of the following characters are not converted by the <c:out> action when the attribute escapeXml is set to false? (Choose one.) | All of the above
Which of the following are invalid uses of the <c:set> action? (Choose three.) | a. <c:set scope="page">value</c:set> b. <c:set value="value" var="${myVar}" /> c. <c:set var="myVar" scope="${scope}">value</c:set>
What is the result of attempting to access the following JSP page source? You can assume that the file countries.txt exists in the location specifi ed. (Choose one.)<html xmlns:mytags="http://www.osborne.com/taglibs/mytags"xmlns:jsp="http://java.sun.com/JSP/Page"xmlns:c="http://java.sun.com/jsp/jstl/core" ><jsp:output omit-xml-declaration="true" /><jsp:directive.page contentType="text/html" /><jsp:directive.page import=�oejava.io.*" /><head><title>Question 9</title></head><body><c:import url="/countries.txt" varReader="myReader" /><jsp:scriptlet>Reader r = (Reader) pageContext.getAttribute("myReader");out.write(r.read());</jsp:scriptlet></body></html> | The first character of the fi le countries.txt is sent to page output.
What is the minimum number of attributes that must be specified in the <c:forEach> action? (Choose one.) | 1-items
Which of the following characteristics must a Java class have if it contains one or more EL functions? (Choose three.) | A method that is public. A method that is static. A main method (signature: public static void main(String[] args))
Which of the following represents a correct function declaration in the tag library descriptor?(Choose one.) | <function><description>Taxation Function</description><name>netincome</name><function-class>webcert.ch08.ex0803.Taxation.class</function-class><function-signature>java.lang.String calcNetIncome(double, double,double, java.lang.String)</function-signature></function>
What is the result of attempting to access the following JSP? You can assume that the EL functions are legally defi ned, that the EL function mytags:divide divides the fi rst parameter by the second parameter, and that the EL function mytags:round rounds the result from the first parameter to the number of decimal places expressed by the second parameter.(Choose one.)<html><%@ taglib prefix="mytags" uri="http://www.osborne.com/taglibs/mytags" %><head><title>Question 13</title></head><body><p>${mytags:round(${mytags:divide(arg1, arg2)}, 2)}</p></body></html> | Translation error (in code generation).
Where in JSP page source can EL functions be used? (Choose two.) | In the body of a tag where body-content is set to scriptless. In the body of a tag where body-content is set to JSP
Consider these pairings of Java method signatures and EL function method signatures for a TLD file. Which pairings go together and will work? (Choose two.) | Java: public static String getNameForId(int id) TLD: java.lang.String getNameForId(int) b. Java: public static java.lang.String getNameForId(java.lang.String id) TLD: java.lang.String getNameForId(java.lang.String)
Which of the following are valid statements relating to the <body-content> element in the tag library descriptor? (Choose two.) | To permit EL but not JSP expressions, <body-content> should be set to scriptless. b. JSP expressions are legal in the body of a custom action whose <body-content> is set to tagdependent, but they will not be translated.
For the given interfaces, which of the following are valid sequences of method calls according to custom tag life cycle? (Choose three.) | Tag: setPageContext, setParent, doStartTag, doEndTag. IterationTag: doStartTag, doAfterBody, doAfterBody, doAfterBody. BodyTag: doStartTag, setBodyContent, doInitBody, doAfterBody
Given the following JSP and tag handler code, what is the result of accessing the JSP? (Choose one.) JSP Page Source<%@ taglib prefix="mytags" uri="http://www.osborne.com/taglibs/mytags" %><html><head><title>Questions</title></head><body><p><% session.setAttribute("first", "first"); %><mytags:question01 />${second}</p></body></html>Tag Handler Code for <mytags:question01 />(imports missing, but assume they are correct)public class Question01 extends TagSupport {public int doStartTag() throws JspException {Writer out = pageContext.getOut();try {out.write("" + pageContext.getAttribute("first"));} catch (IOException e) {e.printStackTrace();}pageContext.setAttribute("second", "second", PageContext.SESSION_SCOPE);return super.doStartTag();}} | null second
Which of the following snippets of code, if inserted into the doStartTag() method of a tag handler class extending TagSupport, would compile? (Choose three.) | pageContext.getSession().getId(); b. pageContext.getException().getStackTrace(); c. pageContext.getExpressionEvaluator();
Identify true statements about the exception implicit object in tag handler code.(Choose two.) | It can be obtained through the page context’s getError() method. The JSP page housing the tag must have page directive isErrorPage set to true for exception to be non-null in the tag handler code.
Which of the following methods are available in the java.servlet.jspPageContext class? (Choose three.) | getServletConfig b. include c. getErrorData
For a tag implementing the SimpleTag interface, which of the following method sequences might be called by the JSP container? (Choose two.) | setJspContext, setAnAttribute, doTag. setJspContext, setParent, doTag
Which of the following techniques causes the JSP container to skip the rest of the page after processing a custom action implementing the SimpleTag interface? (Choose one.) | Throwing a SkipPageException within the doTag() method
Consider the following JSP page code and SimpleTag code. What is the output from tag<mytags:question08> to the requesting JSP page? You can assume that all necessary deployment descriptor and tag library descriptor elements are set up correctly. (Choose one.)JSP Page Code:<%@ taglib prefix="mytags" uri="http://www.osborne.com/taglibs/mytags"%><html><head><title>Question08</title></head><body><p><mytags:question08>a</mytags:question08></body></html>SimpleTag Tag Handler Code for <mytags:question08>:import java.io.IOException;import java.io.StringWriter;import javax.servlet.jsp.JspException;import javax.servlet.jsp.tagext.JspFragment;import javax.servlet.jsp.tagext.SimpleTagSupport;public class Question08 extends SimpleTagSupport {public void doTag() throws JspException, IOException {JspFragment fragment = getJspBody();StringWriter sw = new StringWriter();for (int i = 0; i < 3; i++) {fragment.invoke(sw);String s = "b" + sw;sw.write(s);fragment.invoke(null);}}} | aaa
Identify true statements about tag declarations in tag library descriptors from the following list. (Choose three.) | a. A tag whose <body-content> is declared as JSP must follow the classic tag model.b. Simple tags are commonly declared with a <body-content> of scriptless.c. If a simple tag is declared with a <body-content> of �oeempty,� the JSP container makes one less method call on the simple tag handler class.
Consider the following JSP page code and SimpleTag code. What is the output from tag<mytags:question08> to the requesting JSP page? You can assume that all necessary deployment descriptor and tag library descriptor elements are set up correctly. (Choose one.) JSP Page Code:<%@ taglib prefix="mytags" uri="http://www.osborne.com/taglibs/mytags"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %><html><head><title>Question 10</title></head><c:set var="counter">1</c:set><body><p><mytags:question10><c:forEach begin="${counter}" end="3">${counter}</c:forEach></mytags:question10></p></body></html>SimpleTag Tag Handler Code for <mytags:question08>:package webcert.ch09.questions09;import java.io.IOException;import javax.servlet.jsp.JspContext;import javax.servlet.jsp.JspException;import javax.servlet.jsp.tagext.SimpleTagSupport;public class Question10 extends SimpleTagSupport {public void doTag() throws JspException, IOException {JspContext context = ....for (; i < 4; i++) { | 111 22 3
From the list, identify correct techniques to make tag fi les available in a JSP page or JSP document. (Choose two.) | a. <html xmlns:mytags="urn:jsptagdir:/WEB-INF/tags/"> b. <%@ taglib prefix="mytags" tagdir="/WEB-INF/tags" %>
What is the result of accessing the following tag fi le? (Line numbers are for reference only and should not be considered part of the tag fi le source.) (Choose one.)01 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>02 <c:set var="character">65</c:set>03 <c:forEach begin="1" end="10" varStatus="loopCount" >04 <% char c = (char)Integer.parseInt(pageContext.getAttribute("character").toString());05 pageContext.setAttribute("displayCharacter", new Character(c));07 %>08 ${displayCharacter}09 <c:set var="character">${character + 1}</c:set>10 </c:forEach> | Translation error at line 4
Which of the following are directives you might find in a tag file? (Choose three.) page | a. tag b. variable c. attribute
Consider the following hierarchy of actions. <c:if> is from the JSTL core library, and <a: tagA> and <a:tagB> are classic custom actions.<a:tagA><c:if test="${true}"><a:tagB /></c:if></a:tagA>What options does tagB have for obtaining the enclosing instance of tagA? | a. Use TagSupport.findAncestorWithClass() b. Invoke getParent().getParent(). c. Use SimpleTagSupport.findAncestorWithClass()
Which of the following could not be returned by either of the getParent() methods in the JSP class libraries? (Choose two.) | a. An instance of an HTML tag b. An instance of an XML template tag in a JSP document
What methods can you execute on the reference myAncestor at ??? in the code snippet below? (Choose two.) JspTag myAncestor = SimpleTagSupport.findAncestorWithClass(MyTagClass); myAncestor.??? | a. notifyAll() b. hashCode()
What strategies might a parent tag use to get hold of a child tag handler instance?(Choose two.) | a. Classic model: Child gets hold of parent and provides the parent with its own reference to the child. Parent uses the reference in doAfterBody() method. b. Simple model: Child gets hold of parent and provides the parent with its own reference to the child. Parent uses the reference after a call to JspFragment.invoke().
Which of the following patterns can reduce network overhead? (Choose one.) | a. Business Delegate b. Service Locator c. Transfer Object d. B, C, and D above ANS: D
Which pattern insulates the presentation client code from volatility in business APIs?(Choose one.) | a. Business Delegate
A company has a message queuing system, accessible with complex Java APIs. The company wants a new web application but also wants to minimize the specialized knowledge required to write business code that accesses the queuing system. Which J2EE patterns might best help the company with this problem? (Choose two.) | a. Service Locator b. Business Delegate
From the following list, choose benefits that are usually conferred by the Transfer Object pattern. (Choose two.) | a. Reduces network traffic b. Packages data into an accessible form
A company wants to structure its development department on specialist lines so that web designers can concentrate on page layout and Java developers can concentrate on business API development. Which pattern should the company use in application development to best support its organizational aims? (Choose one.) | a. Model View Controller
From the following list, choose benefits that are usually conferred by the Service Locator pattern. (Choose two.) | a. Reduces strain on the Business Delegate pattern b. Encapsulates naming service code
Which of the following patterns might best be used to reject requests from a host machine with �oeuk� in its domain name? (Choose one.) | a. Intercepting Filter
From the following list, choose benefi ts that are usually conferred by the Model View Controller pattern. (Choose two.) | a. Separation of concerns b. Better project management
Which of the following patterns might be used to dispatch a view containing an applicationfriendly error message? (Choose one.) | a. Front Controller
From the following list, choose benefi ts that are usually conferred by the Business Delegate pattern. (Choose two.) | a. Presentation code stability b. Better network performance
Which scenario below could best use Transfer Object as a solution? (Choose one.) | a. An application appears to have hit a bottleneck when using some EJBs. On analysis, it appears that there are numerous method calls to retrieve individual attributes.
From the following list, choose benefi ts that are usually conferred by the Front Controller pattern. (Choose three.) | a. Acts a gateway for requests to the system b. Centralizes control of navigation c. Reduces complexity of links in JSPs
Which of the patterns below will defi nitely reduce the lines of code in an application? (Choose one.) | a. None of the above
From the following list, choose reasonable applications for the Intercepting Filter pattern. (Choose one.) | a. All of the above
Which of the patterns below might reduce the lines of code in an application? (Choose one.) | a. All of the above
Message-driven beans are classes that implement 2 interfaces : | a. javax.ejb.MessageDrivenBean b. javax.jms.MessageListener
Which are the types of messaging domains ? (choose 2) | a. Publish/Subcribe b. Point-to-Point
Select the correct JMS programming model | a. Locate the JMS Driver ->Create a JMS connection ->Create a JMS session ->Create a JMS producer or a JMS consumer -> Send or receive message
Message-driven beans do not have any return value | a. False
Select the word to replace ??? to make the diagram about messaging domain correct | a. Topic
A ____ subscription to a topic means that a JMS subscriber receives all message even if the subscriber is inactive | a. Durable
In ejb-jar.xml file, <persistence-type> element value is __________ | a. Bean or Container
Entity bean is ______ | a. a persistent data component
ejbCreate() method of entity bean class returns ______ | a. primary key
create() method of entity home interface returns _________ | a. null
select CORRECT statement (choose 2) | a. Entity beans represent persistent state objects (things that don't go away when user goes away) b. Session beans model a process or workflow (actions that are started by the user and that do away when user goes away)
The _______ class makes every entity bean different | a. primary key
The top three values of EJB are (choose 3): | a. Portability is easier b. Rapid Application Development c. It is agreed upon by the industry
Which is not the players in the EJB Ecosystem? (choose 1): | a. End User
The ______ is the overall application architect .This party is responsible for understanding how various components fit together and writes the application that combine components. | a. Application Assembler
which is not the role of EJB Deployer? | a. Write the code that calls on components supplied by bean providers
The ________ supplies business components,or enterprise beans | a. Bean provider
Is the statement true or false. The deployment descriptor of a web application must have the name web.xml.In the same way the tag library descriptor file must be called taglib.xml | a. False
Given the following JSP and Tag handler code,what is the result of accessing the JSP ? JSP Page Source <html> <body><%@taglib uri = "test_taglib" prefix = "myTag"%><% session.setAttribute("first", "first");%><myTag:TestTag/><br><%=session.getAttribute("second")%></body></html>Tag Handler Code for <myTag:TestTag/>pakage examples;import java.io.*;import javax.servlet.jsp.*;import javax.servlet.jsp.tagext.*;public class TestTag extends TagSupport{private PageContext pageContext;public void setPage(PageContextpage){this.pageContext=page;}public int doStartTag() throws JspException {try{String first = pageContext.getSession().getAttribute("first").toString();pageContext.getOut().write(first);pageContext.setAttribute("second", "second", PageContext.PAGE_SCOPE);}catch(IOException){throw new JspException(i.getMessage());}return SKIP_BODY;}public int doEndTag() throws JspException{return EVAL_PAGE;}public void release(){}}Assume *.tld and web.xml files are correct. | a. SKIP_PAGE
A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive <%@taglib uri = "..." prefix="..."%> Which of the following specifies the correct purpose of prefix attribute.SELECT the one correct answer. | a. The prefix attribute is used in front of a tag defined within the tag library
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is need to do this. The InventoryItem has private instance variables to store the item information:10.private int itemld;11.private String name;12.private String description;Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable? (choose one) | a. setItemld(int itemld)
Name the class that includes the SetSession method that is used to get the httpSession object | a. HttpSevletRequest
Which of the following are potential legal of JSP source ? (choose 2) | a. <jsp:useBean id = "beanName1" class="a.b.MyBean"type="a.b.Myinterface"/> b. <% String myValue = "myValue";%> <jsp:setProperty name ="beanName1" property="soleProp" value ' "<%=myValue%>"/>
<html><body><form action="loginPage.jsp">Login ID:<input type = "text " name = "loginID"><br>Password:<input type = "password" name = "password"><br><input type="submit" value="Login"><input type="reset" value =Reset"></form></body></html>Study the above html code: Assume that user clicks button Reset.What is the correct statement ? (choose 1) | a. Nothing changes
Which syntax is correct for JSP Declarations : | a. <% code %>
Review the following scenario,then identify which security mechanisms would be important to fulfill the requirement (choose 2) An online magazine company wishes to protect part of its web site content,to make that part avalaible only to users who pay a monthly subcription.The company wants to keep client, network and server processing overheads down: Theft of content is unlikely to be an issue,as is abuse of user IDs and passwords through network snooping. | a. Authentication b. Authorization
Which security mechanism limits access to the availability of permitted groups of users or programs ? (choose one) | a. Authorization
Which security mechanism proves that data has not been tampered with during its transit through the network ? (choose 1) | a. Data integrity
The following web is defined as the custom form login page for authentication. Assuming that you have attempted to access a protected resource and been redirected to this web page, what is the result of filling in the user name and password fields and pressing submit (choose 1)<html><head><title>login Form</title></head><body><form action="jsecuritycheck" method="POST"><br /> Name:<input type = "text" name = jusername" /><br /> Password:<input type = "pasword" name = jpassword" /><br /><input type = "submit" value = "Log In" /></form></body></html> | a. The page is redisplay
Which is correct JDBC-ODBC driver name? | a. sun.jdbc.odbc.JdbcOdbcDriver
Choose three correct statements in JDBC | a. getObject b. getText c. getInt d. getString
Which is correct sequence for a JDBC execution? | a. Load Driver -> Connection -> Statement -> ResultSet
Which are the correct statements of Connection object? (Choose two) | a. createStatement(int, int); b. createStatement();
Which are the correct statements of ResultSet object? (Choose three) | a. executeQueries() b. execute() c. executeUpdate()
To send text outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | a. getWriter
Which of these is true about deployment descriptors. Select the one correct answer | a. The order of elements in deployment descriptor is important. The elements must follow a specific order
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Do not include the element in enclosing parenthesis | a. error-page
______ is a set of java API for executing SQL statements. | a. JDBC
JDBC supports ______ and ______ models. | a. Two-tier and three-tier
URL referring to databases use the form: | a. jdbc:odbc:datasoursename
Study the statements:1)When a JDBC connection is created, it is in auto-commit mode 2)Once auto-commit mode is disabled, no SQL statements will be committed until you call the method commit explicitly | a. Both 1 and 2 are true
The ______ class is the primary class that has the driver information. | a. DriverManager
The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the one correct answer. | a. HttpServletResponse
Name the method defined in the HttpServletResponse class that may be used to set the content type. Select the one correct answer. | a. setContent
Which of the following statement is correct. Select the one correct answer. | a. The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method.
The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter. Select the one correct answer. | a. SC_NOT_FOUND
To send binary output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | a. getOutputStream
To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | a. getWriter
Is the following statement true or false. URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL. | a. True
Which of the following are correct statements? Select the two correct answers. | a. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext. b. The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method
A user types the URL http://www.javaprepare.com/scwd/index.html . Which HTTP request gets generated. Select the one correct answer. | a. GET method
Which HTTP method gets invoked when a user clicks on a link? Select the one correct answer. | a. GET method
When using HTML forms which of the folowing is true for POST method? Select the one correct answer. | a. POST method sends data in the body of the request.
Which of the following is not a valid HTTP/1.1 method. Select the one correct answer. | a. COMPARE method
Name the http method used to send resources to the server. Select the one correct answer. | a. PUT method
Name the http method that sends the same response as the request. Select the one correct answer. | a. TRACE method
Which three digit error codes represent an error in request from client? Select the one correct answer. | a. Codes starting from 400
Name the location of compiled class files within a war file? Select the one correct answer. | a. /WEB-INF/classes
Which of the following is legal JSP syntax to print the value of i. Select the one correct answer | a. <%int i = 1;%> <%= i %>
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp? name="John". The test.jsp contains the following code.<%! String myName=request.getParameter();%><% String test= "welcome" + myName; %><%= test%> | a. The program gives a syntax error because of the statement <%! String myName=request.getParameter();%>
Which of the following correctly represents the following JSP statement. Select the one correct answer.<%=x%> | a. <jsp:expression>x</jsp:expression>
Which of the following correctly represents the following JSP statement. Select the one correct answer. <%x=1;%> | a. <jsp:scriptlet>x=1;</jsp:scriptlet>
What gets printed when the following JSP code is invoked in a browser. Select the one correct answer.<%= if(Math.random() < 0.5) %> hello<%= } else { %>hi<%= } %> | a. The JSP file will not compile.
Which of the following are correct. Select the one correct answer. | a. To use the character %> inside a scriptlet, you may use %\> instead.
What gets printed when the following is compiled. Select the one correct answer. <% int y = 0; %><% int z = 0; %><% for(int x=0;x<3;x++) { %><% z++;++y;%><% }%><% if(z<y) {%><%= z%><% } else {%><%= z - 1%><% }%> | a. 2
Which of the following JSP variables are not available within a JSP expression. Select the one correct answer. | a. httpsession
A bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> Which of the following statements may be used to set the of color property of the bean. Select the one correct answer. | a. <jsp:setProperty name="fruit" property="color" value="white"/>
A bean with a property color is loaded using the following statement<jsp:usebean id="fruit" class="Fruit"/>What happens when the following statement is executed. Select the one correct answer.<jsp:setProperty name="fruit" property="*"/> | a. All the properties of the fruit bean are assigned the values of input parameters of the JSP page that have the same name.
Is the following statement true or false. If the isThreadSafe attribute of the page directive is false, then the generated servlet implements the SingleThreadModel interface. | a. True
Which of the following represents a correct syntax for usebean. Select the two correct answers. | a. <jsp:usebean id="fruit type ="String"/> b. <jsp:usebean id="fruit type ="String" beanName="Fruit"/>
Name the default value of the scope atribute of <jsp:usebean>. | a. page
Which of these are legal attributes of page directive. Select the two correct answers. | a. errorPage b. session
Which of the following represents the XML equivalent of this statement <%@ include file="a.jsp"%>. Select the one correct statement | a. <jsp:directive.include file="a.jsp"/>
Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output. <% int sum = 0;for(j = 0; j < 10; j++) { %>// XXX --- Add j to sum<% } %>// YYY --- Display ths sum Which statement when placed at the location XXX can be used to compute the sum. Select the one correct statement | a. <% sum = sum + j; %>
Now consider the same JSP example as last question. What must be added at the location YYY to print the sum of ten numbers. Select the one correct statement | a. <%= sum %>
JSP pages have access to implicit objects that are exposed automatically. One such object that is available is request. The request object is an instance of which class? | a. HttpServletRequest
JSP pages have access to implicit objects that are exposed automatically. Name the implicit object that is of type HttpSession. | a. session
A Java bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> What is the effect of the following statement. <jsp:setproperty name="fruit" property="color"/>Select the one correct answer. | a. If there is a non-null request parameter with name color, then its value gets assigned to color property of Java Bean fruit.
The page directive is used to convey information about the page to JSP container. Which of these are legal syntax of page directive. Select the two correct statement | a. <%@ page info="test page" session="false"%> b. <%@ page session="true" %>
Is the following JSP code legal? Select the one correct statement. <%@page info="test page" session="false"%> <%@page session="false"%> | a. No. This code will generate syntax errors.
A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify that the JSP page is generating an XML file. | a. contentType
A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its complete package name each time, we want to just use ArrayList. Which attribute of page directive must be specified to achieve this. Select the one correct answer. | a. import
Which of these are true. Select the two correct answers. | a. The default value of isThreadSafe attribute of page directive is true. b. When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page.
Which of the following are examples of JSP directive. Select the two correct answers. | a. include b. page
Which of these is true about include directive. Select the one correct answer. | a. When using the include directive, the JSP container treats the file to be included as if it was part of the original file.
Name the implicit variable available to JSP pages that may be used to access all the other implicit objects. | a. pageContext
When implementing a tag, if the tag just includes the body verbatim, or if it does not include the body, then the tag handler class must extend the BodyTagSupport class. Is this statement true of false. | a. False
Fill in the blanks. A tag handler class must implement the javax.servlet.jsp.tagext.Tag interface. This is accomplished by extending the class TagSupport or another class named in one of the options below. Select the one correct answer. | a. BodyTagSupport
Is this statement true or false. The deployment descriptor of a web application must have the name web.xml . In the same way the tag library descriptor file must be called taglib.xml . | a. False
A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive - <%= taglib uri="..." prefix="..."%> Which of the following specifies the correct purpose of prefix attribute. Select the one correct answer. | a. The prefix attribute is used in front of a tagname of a tag defined within the tag library.
A JSP file uses a tag as <myTaglib:myTag>. The myTag element here should be defined in the tag library descriptor file in the tag element using which element. Select the one correct answer. | a. name
Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers. | a. tlib-version b. short-name
Name the element within the tag element that defines the name of the class that implements the functionality of tag. Select the one correct answer. | a. tag-class
Which of these are legal return types of the doStartTag method defined in a class that extends TagSupport class. Select the two correct answers. | a. EVAL_BODY_INCLUDE b. SKIP_BODY
Which of these are legal return types of the doAfterBody method defined in a class that extends TagSupport class. Select the two correct answers. | a. EVAL_BODY_AGAIN b. SKIP_BODY
Which of these are legal return types of the doEndTag method defined in a class that extends TagSupport class. Select the two correct answers. | a. EVAL_PAGE b. SKIP_PAGE
Which element of the servlet element in the deployment descriptor is used to specify the parameters for the ServletConfig object. Select the one correct answer. | a. init-param
Which of these is true about deployment descriptors. Select the one correct answer. | a. The order of elements in deployment descriptor is not important. The elements can follow any order.
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Select the one correct answer. | a. error-page
Which of these is a correct fragment within the web-app element of deployment descriptor. Select the one correct answer. | a. <error-page><exception-type> mypackage.MyException</exception-type><location> /error.jsp</location></error-page>
Which element of the deployment descriptor of a web application includes the welcome-file-list element as a subelement. Select the one correct answer. | a. web-app
Which of these is a correct fragment within the web-app element of deployment descriptor. Select the two correct answer. | a. <error-page><error-code>404</error-code><location>/error.jsp</location></error-page> b. <error-page><exception-type>mypackage.MyException</exception-type><location>/error.jsp</location></error-page>
Which of these is a correct example of specifying a listener element resented by MyClass class. Assume myServlet element is defined correctly. Select the one correct answer. | a. <listener><listener-class>MyClass</listener-class></listener>
The root of the deployment descriptor is named as | a. web-app
With in a context-param element of deployment descriptor, which of the following element is required? | a. param-name
Which of these is not a valid top level element in web-app | a. param-name
Which of the follwing are mandatory elements within the filter element. Select two correct answers. | a. filter-name b. filter-class
Which of these is not a valid value for dispatcher element of filter-mapping. Select the one correct answer. | a. RESPONSE
Which of these is not correct about the filter-mapping element of web-app. Select the one correct answer. | a. dispatcher element can be declared zero to three times in the filter-mapping element.
What gets printed when the following expression is evaluated? Select the one correct answer. {4 div 5} | a. 0.8
What gets printed when the following expression is evaluated? Select the one correct answer.${12 % 4} | a. 0
What is the effect of executing the following JSP statement, assuming a class with name Employee exists in classes package. <%@ page import = "classes.Employee" %><jsp:useBean id="employee" class="classes.Employee" scope="session"/><jsp:setProperty name="employee" property="*"/> | a. The code sets the values of all properties of employee bean to matrching parameters in request object.
What is the effect of evaluation of following expression? Select the one correct answer. ${(5*5) ne 25} | a. false
What is the effect of evaluation of following expression? Select the one correct answer. ${'cat' gt 'cap'} | a. true
How many numbers are printed, when the following JSTL code fragment is executed? Select the one correct answer. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:forEach var="item" begin="0" end="10" step="2">${item}</c:forEach> | a. 6
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="item" value="2"/><c:if test="${var==1}" var="result" scope="session"><c:out value="${result}"/></c:if> | a. Nothing gets printed.
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="item" value="2"/><c:forEach var="item" begin="0" end="0" step="2"><c:out value="${item}" default="abc"/></c:forEach> | a. 0
Which numbers gets printed when the following JSTL code fragment is executed? Select the two correct answers.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="j" value="4,3,2,1"/><c:forEach items="${j}" var="item" begin="1" end="2"><c:out value="${item}" default="abc"/></c:forEach> | a. 2 b. 3
Which of these represent the correct path for the core JSTL library in JSTL version 1.1? Select the one correct answer. | a. http://java.sun.com/jsp/jstl/core
Which statement is true about java server page life cycle: | a. All serverlet methods are accessible from the jsp(init() method. b. Jsp Service() method is called from the generate Servlet’s Service() method.
http Sesision object live on the server | a. True
Whenever a method does not want to handle exception using the try block, the _____ is used? | a. Throws
_____ has a name, single value, optional such as comment maximum age, version name | a. Cookie
A<servlet> element can include to many <init-parent> elements: these action passing initialization parameter Infomation from the deployment descriptor to all servlet? | a. True
A ____ dialogs prevent user input in the other windows in the application unit dialog is close | a. Modal
Session death can come about through an explicit call(in servlet) to http session invalidate() | True
A class should extends httpServlet and override doGet(), doPost() depend on whether the data is being sent by get or post | a. True
To be a serverlet, a class should extend Http Serverlet and override doGet or doPost,depending on whether the data is being sent by GET on by Post | a. True
Swing components can’t be combine with AWT | a. False
How many sesssion (Http Serverlet Request) time out mechanisms | a. 3
The special directory /WEB-INF/ class contain JAR files with supporting libraries of code | a. False
Class implement FIFO queue | a. Link list
Which of the following are valid iteration mechanisms in jsp? | a. <% int i = 0; for(;i<5; i++){ %>"Hello World";<% i++;}%>
Which of the following methods will be invoked if the doStartTag() method of a tag returns Tag.SKIP_BODY? | a. doEndTag()
Select the BEST case to use message-driven bean?(Choose one) | a. Need to avoid tying up server resources andneed the applications to process messages asynchronously
Which of the following method can be used to add cookies to a servlet response? | a. HttpServletResponse.addCookie(Cookie cookie)
The page directive is used to convey information about the page to JSP container. Which statement is legal page directive. Select one correct statement | a. <%@ page info="test page" session="false"%>
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/Final/test.jsp?name=John. The test.jsp contains the following code. <% String myName=request.getParameter("name");%> <% String test= "Welcome " + myName; %> <%=test%> What is the output? | a. The page display "Welcome John"
What will happen when a servlet makes the following call within its doGet() method? getServletContext().setAttribute("userid", userid); | a. The userid attribute is placed in application scope.
Which of the following is true statement about the JavaServer Page life cycle? (Choose one) | a. The _jspService() method is called from the generated servlet’s service() method.
Which is NOT the main type of JSP constructs that you embed in a page? | a. actions
Which statement(s) about Servlet Life Cycle is(are) correct? (Choose one) | a. All the others
_______________ sends a request to an object and includes the result in a JSP file. | a. <jsp:include>
Which syntax is correct for JSP Declarations? | a. <%! code %>
Which statement is correct about Container-managed persistent (CMP)? | a. Container-managed persistent persisted by the Enterprise Java Beans container
Your jsp page uses classes from java.util package. Which of the following statement would allow you to import the package? (Choose one) | a. <%@ page import="java.util.*"%>
Which of the following is a valid standard action that can be used by a jsp page to import content generated by another JSP file named another.jsp? | a. <jsp:include page='another.jsp'/>
Which class that includes the getSession method that is used to get the HttpSession object? | a. HttpServletRequest
Which of the following statement correctly store an object associated with a name at a place where all the servlets/jsps of the same webapp participating in a session can access it? Assume that request, response, name, value etc. are references to objects of appropriate types. (Choose one) | a. request.getSession().setAttribute(name, value);
If a ______________is being used then all the operations need to be written by the developer to a persistent API. | a. Bean-Managed persistent entity bean
Which is the CORRECT statement? | a. Entity beans represent persistent state objects (things that don’t go away when the user goes away).
Study the statements:1) URL rewriting may be used when a browser is disabled cookies.2) In URL encoding the session id is included as part of the URL.Which is the correct option? | a. Both 1 and 2 are true
A ___________________________ in EJB is an object that is deploy on any EJB Server | a. Component
A ……………….. manages the threading for the servlets and JSPs and provides the necessary interface with the Web server. | a. Web Container
create() method of entity bean home interface returns _____________ | a. null
The _________________ is the overall application architect. This party is responsible for understanding how various components fit together and writes the applications that combine components. | a. Application Assembler
Identify correct statement about a WAR file.(Choose one) | a. It contains web components such as servlets as well as EJBs.
Which of the following statement is correct? (choose one) | a. Authorization means determining whether one has access to a particular resource or not.
A session bean being used by a client can also be used by another client. | a. False
Which of the following is example of JSP directive? Select one correct answer. | a. include
Which interface and method should be used to retrieve a servlet initialization parameter value?(Choose one) | a. ServletConfig : getInitParameter(String name)
Which of the following classes define the methods setStatus(...) and sendError(...) used to send an HTTP error back to the browser? | a. Both are defined in HttpServletResponse.
Which is NOT EJB container? | a. Apache Tomcat 5.5
Which of the statements regarding the following code are correct? public void doPost(HttpServletRequestreq, HttpServletResponse res) throws IOException, ServletException{res.getWriter().print("Hello ");RequestDispatcherrd = getServletContext().getRequestDispatcher("/test.jsp");rd.include(req, res);res.getWriter().print("World");} | a. "Hello" and "World" both will be a part of the output.
Which statement is true? | a. When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page
Which of the following elements are used for error handling and are child elements of <web-app> of a deployment descriptor? | a. <error_page>
Message-driven beans do not have any return value. | a. True
Given the following deployment descriptor:<web-app>context-param><param-name>jdbcDriver</param-name><param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value></context-param><servlet><servlet-name>InitParams</servlet-name><servlet-class>InitParamsServlet</servlet-class></servlet>.. </web-app>What is the outcome of running the following servlet? (Choose one.)public class InitParamsServlet extends HttpServlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throwsServletException, IOException {ServletContextsc = this.getServletContext();PrintWriter out = response.getWriter();out.write("Initialization Parameter is: " + sc.getInitParameter("jdbcDriver"));}} | "Initialization Parameter is: null" returned to the requester
Consider the contents of 2 jsp files:<!-- In File : test.jsp --><html><body><% String s = "Hello"; %>//1 insert LOC here.<%=s%></body></html><!-- In File : test2.jsp --><% s = s+" world"; %>What can be inserted at //1 so that it prints "Hello world" when test.jsp is requested? | a. <jsp:include page="test2.jsp"/>
Which of the following is true about Data Integrity? | a. The information/data is not tampered with, in transit from host to client.
To be a servlet, a class should extend HttpServlet and override doGet or doPost, depending on whether the data is being sent by GET or by POST. | a. True
Name the default value of the scope attribute of <jsp:useBean> | a. page
The properties that characterize transactions are known as ACID properties. | a. True
A web application is located in "helloapp" directory. Which directory should it's deployment descriptor be in? | a. helloapp/WEB-INF
Which statement is correct about Message-Driven Beans exception handling? | a. Message-Driven Beans cannot send any exceptions back to clients
Which statement is correct about Bean-managed persistent (BMP)? | a. Bean-managed persistent persisted by the developer, who write the code for the database access calls
Regarding URL rewriting for session support, which of the following is true? | a. Every URL that the client uses must include jsessionid.
Which syntax is correct for JSP Scriptlets? | a. <% code %>
What is output to the web page on the second access to the same instance of the following JSP?<html><body><%! int x = 0; %><%= x++ %></body></html> | a. 0
Which of these is legal return type of the doStartTag method defined in a class that extends TagSupport class? | a. EVAL_BODY
Select the correct JMS programming model. | a. Locate the JMS Driver->Create a JMS connection->Create a JMS session->Locate the JMS destination->Create a JMS producer or a JMS consumer->Send or receive message.
___________________ includes a static file in a JSP file, parsing the file's JSP elements | a. include directive
Which of the following JSP variable is not available within a JSP expression? Select one correct answer | a. httpsession
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select one correct answer. | a. SC_MOVED_TEMPORARILY
You do not want the user to see the data and the format being passed to your server when the user tries to submit the information for registering with your site. Which HTTP method would you use? (Comment: You can set some hidden parameters such as server location, in the page when the user loads it. Such parameters mean nothing to the user and are generally not displayed. However, determined users can still view them using "View Source" for the page). | a. POST
Which is the BEST case use Container-managed persistent (CMP)? | a. When you require some kind of special bean, like multi-tables, that cannot be completely realized with a single bean
Which statement is correct about Message-Driven Beans?(Choose one) | a. Message-Driven Beans stateless
Every method of the remote interface must throw a ___________________ | a. RemoteException
The instantiation of a session bean is done by the ____________________ while the management of the lifetime of the bean is done by the ___________________________. | a. Container/EJB server
Which of the following code snippet of HTML document are correct structured? | a. <HTML><HEAD><TITLE>...</TITLE>...</HEAD><BODY ...>...</BODY></HTML>
______and _______methods do not apply to stateless session beans. | a. ejbActivate() b. ejbPassivate()
A JavaBeans component has the following field: private boolean enabled; Which pairs of method declarations follow the JavaBeans standard for accessing this field? | a. public void setEnabled( boolean enabled) public booleangetEnabled()
Which of the following is indicated by URL, which is used on the Internet? | a. Information resources(sources) on the Internet
You want to use a bean that is stored in com/enthu/GUI.ser file. Which of following statements correctly defines the tag that accesses the bean? | a. <jsp:useBean id="pref" beanName="com.enthu.GUI" type="com.enthu.GUI"/>
A JSP page has the following page directives: <%@page isErrorPage='false' %> <%@page errorPage='/jsp/myerror.jsp' %>Which of the following implicit object is NOT available to the jsp page? | a. exception
A bean with a property color is loaded using the following statement<jsp:useBean id="fruit" class="Fruit"/>Which of the following statements may be used to print the value of color property of the bean?.Select the one correct answer. | a. <jsp:getProperty name="fruit" property="color"/>
The ____________ interface is a Java interface that enumerates the business methods exposes by the enterprise bean class. | a. remote
A ____________ is a group of operations, which appear as one large operation during execution. | a. Transaction
Select the BEST case to Use Entity Beans? (Choose one) | a. At any given time, only one client has access to the bean instance.
Message-Driven Bean does not have a home interface, local home interface, remote interface, or a local interface. | a. True
For what reason does the following JSP fail to translate and compile?<html><body><%! int x; %><%=x ; %></body></html> | a. Error in JSP Expression.
Which of the following statement is true about the Entity class? | a. E xxxxx ntity class must be declared as top level class
A bean with a property color is loaded using the following statement <jsp:useBean id="fruit" class="Fruit"/> Which statement may be used to set the color property of the bean. | a. <jsp:setProperty name="fruit" property="color" value="white"/>
Which of the following xml fragments correctly define a security constraint in web.xml? (Choose one) | a. <security-constraint> <web-resource-collection><web-resource-name>Info</web-resource-name><url-pattern>/info/*</url-pattern><http-method>GET</http-method></web-resource-collection><auth-constraint><role-name>manager</role-name></auth-constraint></security-constraint>
A JSP expression is used to insert values directly into the output. | a. True
A JSP page will not have access to session implicit variable if: | a. the session attribute of page directive is set to false.
The ______________ is the container-generated implementation of the remote interface. | a. EJB Object
Which of the following is NOT a valid attribute for a useBean tag? | a. className
What gets printed when the following JSP code is invoked in a browser? Select one correct answer. <%= if(Math.random() < 0.5) %> hello<%= } else { %>hi<%= } %> | a. The JSP file will not compile.
Is it possible to share aHttpSession object between a Java Server Page and Enterprise Java Bean? | a. Yes, you can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable
Deployment properties are stored in a _______________________ file. | a. XML
Which is the correct sequence? | a. Jsp page is translated -->jsp page is complied-->jspInit is called ->_jspService is called -->jspDestroy is called
The HttpServletRequest has methods by which you can find out about incoming information such as: | a. All of the others
JavaServer Pages (JSP) technology enables you to mix regular, static HTML with dynamically generated content from servlets. You simply write the regular HTML in the normal manner, using familiar Web-page-building tools. | a. True
Which of the following is INCORRECT statement about implicit objects and scope? | a. application can't be used to access other web application resources
Which statements are BEST describe class attribute of <jsp:useBean class=../> Action? | a. The fully qualified class name of the Java object.
Which of the following XML fragments correctly specify the class name for a servlet in a deployment descriptor of a webapp? | a. <servlet-class>com.abcinc.OrderServlet</servlet-class>
Which of the following statements is correct? Select the one correct answer. | a. The setStatus method defined in the HttpServletRequest class takes an int as an argument and sets the status of Http response
The session time-out value is controlled in which way(s)? | a. Individual Session Setting b. Application Server Global Default d. Web Application Default
Which statements are BEST describe page directive of JSP file? | a. Defines page settings for the JSP container to process
Which of the following lines of code, in the doPost() method of a servlet, uses the RL rewriting approach to maintaining sessions? (Choose one) | a. out.println("<a href='"+response.encodeURL("/servlet/XServlet")+" '>Click here</a>"));
To be a servlet a class should extend HttpServlet and override doGet or doPost, depending on whether the data is being sent by GET or by POST. | a. False
Your web application named "FWorks" uses SpecialMath.class. This is an unbundled class and is not contained in any jar file. Where will you keep this class file? | a. FWorks/WEB-INF/classes
A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its complete package name each time, we want to just use ArrayList. Which attribute of page directive must be specified to achieve this? Select one correct answer. | a. import <@page import="java.util.ArrayList"/>
Which of the following implicit variables should be used by a jsp page to access a resource and to forward a request to another jsp page?(Choose one) | a. application for both
If an HTTP client rrequest is NOT authenticated, what is returned by request.getUserPrincipal()? | a. A null
Host names are translated into IP addresses by web servers. | a. False
Which statements are BEST describe <jsp:getProperty> Action? | a. Gets property in the specified JavaBean instance and converts the result to a string for output in the response.
The brower transmits the username and password to the server without any encryption in which of the following Authentication mechanism? (Choose one) | a. FORM based Authentication
Your jsp page uses java.util.TreeMap.Adding which of the following statement will ensure that this class is available to the paper?(Choose one) | a. <%@page import="java.util.TreeMAp"%>
Which statements are BEST describe uri attribute of <%@taglib uri=...%>directive of JSP file? | a. Specifies the relative or absolute URI of the tag library descriptor.
The two most common HTTP requests are get and put. | a. False
When the client calls a bean, it can in turn call another bean. Do you agree with this statemnt? | a. Disagree
For JSP scopes of request and page, whate type of object is used to store the attribute? | a. HttpServletRequest and PageContext respectively.
The specifications set by EJB need NOT match with those of the component interface. | a. False
Which is NOT a core component of JSP? | a. scriptlets
Each page has its own instances of the page-spoce implicit objects. | a. True
Host names are translated into IP addresses y web servers. | a. True
Which syntax is correct for JSP Expressions? | a. <%=expression%>
The two most common HTTP requests are get and put. | a. True
Identify the technique that can be used to implement'sessions' if the client browser does not support cookies.(Choose one) | a. URL rewriting
Which of the following is true statement about the JavaServer Page life cycle? (Choose one) | a. The_jspService() method is called from the generated servlet's service() method.
Which is NOT the top value of EJB? | a. Easy to upgrade.
The page directive is used convey information about the page to JSP container. which statement is legal page directive. Select one correct statement | a. <%@page info="test page" session="false"%>
The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWeriter method? Select one correct answer. | a. ServletContext
The method getWriter returns an object type PrintWriter. this class has println methods to generate output. Which of these classes define the getWriter method? Select one correct answer. | a. ServletContext
You need to modify deployment descriptor for a web application insalled in MyWebApp directory. Which file would you look for? | a. web.xml in MyWebApp/WEB-INF
Which JSP directive declares the usage of a tag library in a JSP page? | a. taglib
In which of the following cases will the method doEndTag() of a tag handler be invoked? | a. It will be invoked only if doStartTag() or doAfterBody() return Tag.DO_END_TAG.
Which is NOT a basic messaging model in message dreiven bean? | a. Place-to-place
Which security mechanism proves that data has not been tampered with during its transit through the nerwork? | a. Data integrity
What is the implication of using the HTTP GET method for a form submission?(Choose one) | a. The parameters will be appended to the URL as a query string.
Session bean implements ___ interface. | a. javax.ejb.SessionBean
Suppose in a garment shop, a request is made for all the colors available in a particular garment along with the all the sizes and their respective prices, then which session bean will be used thandle such processes? | a. Stateful session bean
Which of the following file is the correct name and location of deployment descriptor of a web application? Assume that the web application is rooted at\doc-root. Select one correct answer | a. \doc-root\WEB-INF\web.xml
Action <jsp:include> is evaluated once at page translation time. | a. False
Which method would you use to put the sesison id the URL to support sessions using URL rewriting? | a. encodeURL() of HttpServletResponse
Servlets usually are used on the client side of a networking application. | a. False
Which is true about RMI? | a. RMI allows objects to be send from one computer to another
Which component can use a container-managed entity manager with an extended persistent context? | a. Only stateful session beans
Which is NOT responsibility of the business tier in a multitier web-based application with web, business, and EIS tiers? | a. To integrate with the legacy applications
The JavaPersistent API defines the Query interface. Which statement is true about the Query.executeUpdate method? | a. It must always be executed within a transaction
A developer wants to use the Java Persistence query language. Which statement is true? | a. The WHERE clause is used to determine the types of objects to be retrieved from persistent store
A stateful session bean must commit a transaction before a business method | a. False
A developer wants to create a Java Persistence query that returns valid US phone numbers (formatted as 123-456-7890) from a collection of defferently formatted international phone numners. The developer needs only those numbers that begin with 303. Which WHERE clause is correct? | a. WHERE addr.phone LIKE '303-___-____'
Which statement is NOT true about JMS? | a. JMS support both synchronous and asynchronous message passing
Which Java technology provides a unified interface to multiple naming and directory services? | a. EJB
What is the purpose of JNDI? | a. To access various direcoty services using a single interface
Which is NOT provided by the EJB tier in a multitier JEE (J2EE) application? | a. XML Parsing
Which is true about the relationship "A keyboard has 101 keys"? | a. This is a one-to-may relationship
Which statement describe about Message-Driven Beans is correct? (Choose one) | a. The bean mediates between the client and the other components of the application, presenting a simplified view to the client.
Which statement is correct about the Java Persistence API support for the SQL queries? | a. SQL queries are expected to be portable across database
Which statement is true about the EJB 3.0 stateful session beans? | a. Its conversational state is retained acroess method invocations and transactions
A developer must implement a "shopping cart" object for a web-based application. The shopping cart must be able to maintain the state of the cart, but the state is not stored persistently. Which JEE (J2EE) technology is suited to this goal? | a. Stateful session beans
Which type of JEE (or J2EE) component is used to store business data persistently? | a. Entity Bean
Which statement is correct about Java EE client of a message-driven beans? | a. The client can use JNDI to obtain a reference to a message-driven bean instance
Which technology is used for processing HTTP requests and mapping those requests to business objects | a. Servlets
A Java programmer wants to develop a browser-based multitier application for a large bank. Which Java edition (or editions) should be used to develop this system? | a. J2SE and J2EE
Cookies never expire | a. False
Which statements are BEST describe <jsp:useBean> Action? | a. Specifies that the JSP uses a JavaBean instance. This action specifies the scope of the bean and assigns it an ID that scripting components can use to manipulate the bean.
Servlet methods are executed automatically. | a. True
Which of the following method calls can be used to retrieve an object from the session that was stored using the name "userid"? | a. getAttribute("userid");
Given that a servlet has been mapped to /account/*. Identity the HttpServletRequest methods that will return the /* segement for the URL:/myapp.account/*. | a. getPathInfo
When a Web server responds to a request from a browser or other Web client, the response typically consists of: (Choose one) | a. a status line, some reposne headers, and the document.
Which of the following statemtn is a correct JSP directive?(Choose one) | a. <%@tabliburi="http://www.abc.com/tags/util" prefix="util"%>
Which statements are BEST describe id attribute of <jsp:useBean id=.../> Action? | a. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is case sensitive.
JSP ___ let you insert arbitrary code into the servlet's _jspService method (which is called by service). | a. scriptlets
A web application named webmail has a file named folderview.jsp which the user should be able access directly. Which of the following directory may contain this file?(Choose one) | a. /webmail/jsp
Identify correct statement about a WAR file.(Choose one) | a. It is used by web application developer to deliver the web application in a single unit.
Computers that run ____ software make resources available, such as web pages, images, PDF documents and even objects that perform complex task. | a. Web server
Which of these is legal attribute of page directive? | a. errorPage
Which of the following is NOT a technique used for maintaining sessions? | a. sesison.invalidate();
A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify that the JSP page is generating an XML file? | a. <%@page contentType ="text/xml">
The <servlet-mapping> element (in web.xml) provides a means of defining URLs to use the servlet resours. | a. True
Which statements are BEST describe contentType attribute of <%@page contentType=...%> directive? | a. Specifies the MIME type of the data in the response to the client. The default type is text/htmt.
A message-driven bean must commit a transaction before a business method | a. True
Which Java technology provides a unified interface to multiple naming and directory services? | a. JNDI
Which Java technology provides a standard API for publish-subcribe messaging model? | a. JMS
Which is disadvantage of using JEE ( or J2EE) server-side technologies in a web-based application? | a. Complexity
What is the purpose of JNDI? | a. To access various directory services using a single interface
Which is NOT associatied with the business tier in a JEE (J2EE) web-based application? | a. JSP
Which is NOT true about stateless session beans? | a. They are used to represent data stored in a RDBMS
HttpSession objects have a built-in data structure that lets you strore any number of keys and associated values. | a. True
The HttpServletRequest has methods by which you can find out aout imcoming information such as: (choose one) | a. All the above
If you want the same servlet to handle both GET and POST and to take the same action for each, you can simply have doGet call doPost, or vice versa. | a. True
To send text output a response, the following method of HttpServlet Reponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | a. getWriter
Session will automatically become inactive when the amount of time between client accesses exceeds the interval specified by getMaxInactiveInterval. | a. True
HttpSession objects have a built-in data structure that lets you store any number of keys and associated values. | a. True
The HttpServletRequest has methods by which you can find about incoming information such as: (choose one) | a. All the above
Sessions will automatically become inactive when the amount of time between client accesses exceeds the interval specified by getMaxInactiveInterval. | a. True
Servlets are programs that run on a Web servlet, acting as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server. | a. True
We can look up the HttpSession object by calling the getSession method of HttpServletResponse | a. True
The same servlet class can be declared using different logical names in the deployment descriptor. | a. True
___ provides a way to indentify a user across more than one page request or visit to a Web site and to store information about that user. | a. Cookie
The same servlet class can be declared using different logical in the deployment descriptor. | a. True
Session death is more likely to come about through a time-out mechanism. If there is no activity on a session for a predefined length of time, the web container invalidates the session. | a. True
When you obtain a session (using HttpServletRequest.getSession()), the web container manufactures a unique ID string for the session. This is passed as a token between the client and server. | a. True
Session death can come about through an explicit call (in servlet code) to HttpSession.invalidate(); | a. True
How many session (HttpServletRequest) time out mechanisms? | a. 3
Session death is more likely to come about through a time-out mechanism. If these is no activity on a session for a predefined length of time, the web container invalidates the session. | a. True
Which security mechanism limits access to the availability of resources to pemitted groups of users or programs?(Choose one.) | a. Authorization
Which security mechanism proves that data has not been tampered with during its transit through the network?(Choose one.) | a. Data intergrity
Which of these are true. Select the two correct answer. | a. The default value of is ThreadSafe attribute of page directive is true b. When is ThreadSafe attribute of page directive is set to true, a thread is created for each request for the page
Which of the following techniques is likely to return an initalization parameter for a JSP page? (Choose two.) | a. <%String s = getInitParameter("myPam");%> b. <% config.getInitParameter("myPam")%>
___ send a request to an object and includes the result in a JSP file. | a. <jsp:include>
Which security mechanism limits access to the availability of resources to permitted groups of users or programs? (Choose one.) | a. Authorization
You can set a page to be an error page either through web.xml or by adding a page directive_____ | a. <%@page isErrorPage="errorPage.jsp" %>
Given that a servlet has been mapped to /account/*. Identity the HttpServletRequest methods that will return the /account segement for the URI: /myapp/account/*. | c. getPathInfo
Which of the following XML fragments correctly specify the name used for a servlet class in the deployment descriptor of a web application?The outermost tag's name containing servlet properties itself is the name of the servlet. | a. <servlet-name>OrderServlet</servlet-name>
Servlet Container calls the init method on a servlet instance ____ | a. Only once in the life time of the servlet instance.
The path in a URL typically specifies a resource’s exact location on the server. | a. True
Which of these is a correct fragment within the web-app element of deployment descriptor? Select one correct answer. | a. <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page>
HTTP error back to the browser? (Choose one) | c. Both are defined in HttpServletResponse.
The <servlet> element holds declarative information about a servlet. It has only two mandatory subelements—<servlet-name>, a logical name for the servlet, and <servlet-class>, the fully qualified Java class name without the .class extension. | a. True
What would be the best directory in which to store a supporting JAR file for a web application? Note that in the list below, all directories begin from the context root | d. \WEB-INF\lib
Consider the code shown in the exhibit for the init() method of a HTTP servlet.Which of the following LOC "may" correctly retrieve the DBURL parameter at //1?(Assume that servletcontext is a reference to ServletContext for this servlet.)(Choose one)public void init(){Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");// 1 Get DBURL heretheConnection = DriverManager.getConnection(dbUrl, "admin", "admin");} | a. this.getInitParameter("DBURL");
Your web application named "FWorks" uses SpecialMath.class. This is an unbundled class and is not contained in any jar file. | a. FWorks/WEB-INF/classes
Identify the technique that can be used to implement 'sessions' if the client browser does not support cookies.(Choose one) | a. Hidden form fields.
How can you ensure the continuity of the session while using HttpServletResponse.sendRedirect() method when cookies are not supported by the client? | b. By enconding the redirect path with HttpServletResponse.encodeRedirectURL() method.
For application and session JSP scopes, what class of object is used to store the attributes?(Choose one) | d. HttpSession and ServletContext respectively
Your web application logs a user in when she supplies username/password. At that time a session is created for the user. Your want to let the user to be logged in only for 20 minutes. The application should redirect the user to the login page upon any request after 20 minutes of activity. Which of the following HttpSession methods would be helpful to you for implementing this functionality? | b. getLastAccessTime()
Which of the following is NOT a technique used for maintaining sessions? | c. session.invalidate();
The web.xml file for a webapp contains the follwing XML fragment for configuring session timeout.<session-config><session-timeout>300</session-timeout></session-config>What would be the session timeout interval for the sessions created in this web application? | a. 300 minutes
When you obtain a session (using getSession() of HttpServletRequest object), the web container manufactures a unique ID string for the session. This is passed as a token between the client and server. | a. True
Each page has its own instances of the page-scope implicit objects. | a. True
Your jsp page uses java.util.TreeMap. Adding which of the following statement will ensure that this class is available to the page? (Choose one) | a. <%@ page import="java.util.TreeMap"%>
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp? name="John". The test.jsp contains the following code.<%! String myName=request.getParameter();%><% String test= "welcome" + myName; %><%= test%> | b. The program gives a syntax error because of the statement <%! String myName=request.getParameter();%>
Which technique is likely to return an initialization parameter for a JSP page? | b. <% String s = getInitParameter("myParm"); %>
You can set a page to be an error page either through web.xml or by adding a page directive_____ | a. <%@page isErrorPage="true" %>
Which of the given jsp statement is equivalent to<%= userbean.getAge() %> ?Assume that userbean.getAge() returns an integer. (Choose one) | d. <jsp:getProperty name="userbean" method="getAge"/>
A programmer is designing a class to encapsulate the information about an inventory item. A JavaBeans component is needed to do this. The Inventoryltem class has private instance variables to store the item information:10. private int itemId;11. private String name;12. private String description;Which method signature follows the JavaBeans naming standards for modifying the itemld instance variable? | c. setItemId(int itemId)
Which of the following represents a correct syntax for using a Javabean? | c. <jsp:useBean id="fruit" class="Fruit" beanName="Fruit"/>
Which security mechanism limits access to the availability of resources to permitted groups of users or programs? | a. Authorization
Which of the following XML fragments correctly defines a role named "manager" in web.xml? | d. <security-role><role-name>manager</role-name></security-role>
A custom tag can be nested inside another custom tag. | a. true
Identify the correct element is required for a valid <taglib> tag in web.xml (Choose one) | e. <taglib-uri>
What should be the value of <body-content> subelement of element <tag> in a TLD file if the tag should not have any contents as its body? | b. empty
A tag library defines a set of elements that can be inserted into the JSP file. | a. True
Which statement is true about EJB 3.0 containers? | a. javax.naming.initialContext is guaranteed to provide a JNDI name space
A developer must implement a �oeshopping cart� object for a web-based application. The shopping cart must be able to maintain the state of the cart, but the state is not stored persistently. Which JEE (J2EE) technology is suited to this goal? | c. Stateful session beans
Which is true about JEE ( or J2EE)? | c. JEE includes servlet APIs and EJB APIs
Which Java technology provides a standard API for publish-subscribe messaging model? | b. JMS
Which is true about JDBC? | b. The JDBC API is included in J2SE
Which statement is true about both stateful and stateless session beans about bean instances? | a. Bean instances are NOT require to survive container crashes c. A bean with bean-managed transactions must commit or rollback any transaction before returning from a business method
A Java developer needs to be able to send email, containing XML attachments, using SMTP. Which JEE (J2EE) technology provides this capability? | d. JavaMail
Which of the following statement is true about the Entity class? | b. Entity class must be declared as top level class
Which of the following lines of code are correct? (Choose one) | a. @Entitypublic class Company{...}public class Employee extends Company{...} b. @Entitypublic class Company{...}@Entitypublic class Employee extends Company{...} c. public class Company{...}@Entitypublic class Employee extends Company{...}
Which three about JMS are true? (Choose three.) | a. JMS supports an event-oriented approach to message reception. b. JMS supports both synchronous and asynchronous message passing. c. JMS provides a common way for Java programs to access an enterprise messaging system's messages.
Which statement is true? | a. JMS enables an application to provide flexible, asynchronous data exchange.
A Java programmer wants to develop a small application to run on mobile phones. Which Java edition (or editions) are required to develop the application? | a. J2SE and J2ME
Which is true? | a. The JDBC API is included in J2SE.
Which two are true? (Choose two.) | a. J2EE application developers need J2SE. b. J2EE includes servlet APIs and EJB APIs.
Which is true? | a. Threading allows GUI applications to perform lengthy calculations and respond to user events at the same time.
Which two are characteristics of an RDBMS? (Choose two.) | a. An RDBMS represents data using two-dimensional tables. b. Java technologies provide capabilities for connecting a legacy RDBMS to a web application.
Which is true about RMI? | a. RMI allows objects to be sent from one computer to another.
Which statement about threading in Java is false? | a. A thread is a special type of method.
What is the definition of the acronym SQL? | a. Structured Query Language
Which two are true? (Choose two.) | a. SQL commands can be written in applications that use NO Java technologies b. SQL allows you to modify multiple rows in a table with a single command.
Which two are valid representations of operations in UML? (Choose two.) | a. - op(p : P) : P b. + op(param : int) : int
What gets printed when the following expression is evaluated? Select the one correct answer. ${(1==2) ? 4 : 5} | a. 1
What gets printed when the following expression is evaluated? Select the one correct answer.${4 div 5} | b. 0.8
How many numbers gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="item" value="2"/><c:choose><c:when test="${item>0}"><c:out value="1"/></c:when><c:when test="${item==2}"><c:out value="2"/></c:when><c:when test="${item<2}"><c:out value="3"/></c:when><c:otherwise><c:out value="4"/></c:otherwise></c:choose> | b. One number gets printed.
Which numbers gets printed when the following JSTL code fragment is executed? Select the two correct answers.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="j" value="4,3,2,1"/><c:forEach items="${j}" var="item" begin="1" end="2" varStatus="status"><c:out value="${status.count}" default="abc"/></c:forEach> | b. 2 c. 3
Which number gets printed when the following JSTL code fragment is executed? Select the one correct answers.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="j" value="4,3,2,1"/><c:forEach items="${j}" var="item" varStatus="status"><c:if test="${status.first}"><c:out value="${status.index}" default="abc"/></c:if></c:forEach> | a. 1
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp? nam<%! String myName=request.getParameter();%><% String test= "welcome" + myName; %><%= test%>e="John". The test.jsp contains the following code. | b. The program gives a syntax error because of the statement <%! String myName=request.getParameter();%>
Which of the following correctly represents the following JSP statement. Select the one correct answer.<%x=1;%> | e. <jsp:scriptlet>x=1;</jsp:scriptlet>
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select the one correct answer. | b. SC_MOVED_TEMPORARILY
When implementing a tag, if the tag just includes the body verbatim, or if it does not include the body, then the tag handler class must extend the BodyTagSupport class. | b. False
A tag handler class must implement the javax.servlet.jsp.tagext.Tag interface. This is accomplished by extending the class TagSupport or another class named in one of the options below. Select the one correct answer. | d. BodyTagSupport
A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive - <%= taglib uri="..." prefix="..."%> Which of the following specifies the correct purpose of prefix attribute. Select the one correct answer. | d. The prefix attribute is used in front of a tagname of a tag defined within the tag library.
Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers. | a. name d. tag-class
Consider the following HTML code. Which method of MyFirstServlet will be invoked when you click on the url shown by the page? | a. doGet
HTTP is a "stateless" protocol: each time a client retrieves a Web page, it opens a separate connection to the Web server, and the server does not automatically maintain contextual information about a client. | a. True
Which interface can you use to retrieve a resource that belongs to the current web application? | a. ServletContext
Which interface you CANNOT use to obtain a RequestDispatcher Object? | a. ServletContext
Study the statements:1) The context path contains a special directory called WEB-INF, which contains the deployment descriptor file, web.xml.2) A client application may directly access resources in WEB-INF or its subdirectories through HTTP. | a. Only statement 1 is true
Which directory is legal location for the deployment descriptor file? Note that all paths are shown as from the root of the web application directory. | b. \WEB-INF
Which of the following statement correctly store an object associated with a name at a place where all the servlets/jsps of the same webapp participating in a session can access it? Assume that request, response, name, value etc. are references to objects of appropriate types.(Choose one) | a. request.getSession().setAttribute(name, value);
Which of the following lines of code, in the doPost() method of a servlet, uses the URL rewriting approach to maintaining sessions? (Choose one) | a. out.println("<a href=' "+response.encodeURL("/servlet/XServlet")+" '>Click here</a>"));
Which of the following statements is true? (Choose one) | a. Session data is shared across multiple webapps in the same webserver/servlet container.
What is the result of attempting to access the following JSP page?<html><body><%! public String methodA() {return methodB();}%><%! public String methodB() {return "JAD Final Test";}%><h2><%= methodA() %></h2></body></html> | a. "JAD Final Test" is output to the resulting web page.
What is the consequence of attempting to access the following JSP page?<html><body><%!public void _jspService(HttpServletRequest request, HttpServletResponse response){out.write("A");}%><% out.write("B"); %></body></html> | a. Duplicate method compilation error.
Which of the following are correct JSP expressions | a. <%= new Date() %>
Objects with application scope are part of a particular Web application. | a. True
Which of the following is a correct JSP declaration for a variable of class java.util.Date? | a. <%! Date d = new Date(); %>
Which of the following task may happen in the translation phase of JSP page? (Choose one) | a. Creation of the servlet class corresponding to the JSP file.
Select the correct directive statement insert into the first line of following lines of code (1 insert code here): | a. <%@page import='java.util.*' %>
The following statement is true or false?�oeIf the isThreadSafe attribute of the page directive is true, then the generated servlet implements the SingleThreadModel interface.� | a. True
Which of the following statement is a correct JSP directive?(Choose one) | a. <%@ tagliburi="http://www.abc.com/tags/util" prefix="util" %>
Which is NOT a scope of implicit objects of JSP file? | a. application
Which statements are BEST describe <jsp:getProperty> Action? | c. Sets a property in the specified JavaBean instance. A special feature of this action is automatic matching of request parameters to bean properties of the same name.
A bean present in the page and identified as 'mybean' has a property named 'name'. Which of the following is a correct way to print the value of this property? | a. <jsp:getProperty name="mybean" property="name"/>
Which statements are BEST describe errorPage attribute of <%@ page errorPage=….%> directive? | a. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
Which statements are BEST describe property attribute of <jsp:setProperty property=…. /> Action? | a. The ID of the JavaBean for which a property (or properties) will be set.
Which of the following xml fragments correctly define a security constraint in web.xml? (Choose one) | a. <security-constraint><web-resource-collection><web-resource-name>Info</web-resource-name><url-pattern>/info/*</url-pattern><http-method>GET</http-method></web-resource-collection> <user-data-constraint><transport-guarantee>CONFIDENTIAL</transport-guarantee></user-dataconstraint></security-constraint>
You need to make sure that the response stream of your web application is secure. Which factor will you look at? (Choose one) | c. data integrity
Which of the following element are required for a valid <taglib> tag in web.xml?(Choose one) | a. <taglib_uri>
Which of the following deployment descriptor snippets would you use to declare the use of a tag library? | c. <taglib><taglib-uri>http://abc.net/ourlib.tld</taglib-uri><taglib-location>/WEBINF/ ourlib.tld</taglib-location></taglib>
Which of the following elements defines the properties of an attribute that a tag needs? | a. attribute
Which statements are BEST describe prefix attribute of <%@ taglib prefix=…%>directive of JSP file? | a. Specifies the relative or absolute URI of the tag library descriptor.
Which element defined within the taglib element of taglib descriptor file is required? Select one correct answer. | a. Tag
Which is NOT associated with the business tier in a JEE (J2EE) web-based application? | a. JSP
Which is NOT Enterprise Beans? | a. Business Beans
A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB 3.0 session beans need to access this business logic. Which design approach can achieve this requirement? | a. Add adapted home interfaces to EJB 3.0 session beans to make EJB 3.0 and EJB 2.1 session beans interoperable.
Which statement is true about EJB 3.0 stateful session beans and stateless session beans? | a. Both can have multiple remote and local business interfaces
If you want to send an entity object as the pass by value through a remote interface, which of the following statements are valid? (Choose one) | b. @Entitypublic class Employees implements Serializable{...}
Which statement about entity manager is true? | a. A container-managed entity manager must be a JTA entity manager.
Can we use the annotation @PrePassivate for more than one method in a Entity bean? | b. No
Which is NOT a correct statement about entity beans? | c. They are used to implement business processes
Which statement about an entity instance lifecycle is correct? | d. A managed entity instance is the instance associated with a persistence context.
Which is a valid PostConstruct method in a message-driven bean class? | c. @PostConstructprivate void init() {}
Which statement describe about JMS is NOT true? | c. JMS use JNDI to locate the destination
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select one correct answer. | b. SC_MOVED_TEMPORARILY
Study the statements: <question>1) The context path contains a special directory called WEB-INF, which contains the deployment descriptor file, web.xml. <question>2) A client application may directly access resources in WEB-INF or its subdirectories through HTTP. | a. Only statement 1 is true
Which of these is legal attribute of page directive?. | c. errorPage
What is the result of attempting to access the following JSP page?<question><html><question><body><question><%! public String methodA() {<question> return methodB();<question>}<question>%><question><%! public String methodB() {<question> return "JAD Final Test";<question>}<question>%><question><h2><%= methodA() %></h2><question></body><question></html> | a. "JAD Final Test" is output to the resulting web page.
What is the consequence of attempting to access the following JSP page?<question><html><question><body><question><%!<question> public void _jspService(HttpServletRequest request, HttpServletResponse response) {<question> out.write("A");<question> }<question> %><question><% out.write("B"); %><question></body><question></html> | a. Duplicate method compilation error.
The following statement is true or false? <question>�oeIf the isThreadSafe attribute of the page directive is true, then the generated servlet implements the SingleThreadModel interface.� | a. True
Which of the following xml fragments correctly define a security constraint in web.xml? (Choose one) | a. <security-constraint>a. <web-resource-collection>a. <web-resource-name>Info</web-resource-name>a. <url-pattern>/info/*</url-pattern>a. <http-method>GET</http-method>a. </web-resource-collection>a. <user-data-constraint>a. <transport-guarantee>CONFIDENTIAL</transport-guarantee>a. </user-data-constraint>a. </security-constraint>
Which of the following deployment descriptor snippets would you use to declare the use of a tag library? | c. <taglib> c. <taglib-uri>http://abc.net/ourlib.tld</taglib-uri>c. <taglib-location>/WEB-INF/ourlib.tld</taglib-location>c. </taglib>
Which is NOT true about stateless session beans? | c. They are used to represent data stored in a RDBMS
If you want to send an entity object as the pass by value through a remote interface, which of the following statements are valid? (Choose one) | b. @Entity b. public class Employees implements Serializable{b. ...b. }
Which is a valid PostConstruct method in a message-driven bean class? | c. @PostConstruct c. private void init() {}
Which statement describe about Message-Driven Beans is correct? (Choose one) | a. Message-Driven Beans are stateful
Which of the following are valid iteration mechanisms in jsp? | <% int i = 0; for(;i<5; i++) { %> "Hello World"; <% i++; } %>
Which of the following methods will be invoked if the doStartTag() method of a tag returns Tag.SKIP_BODY? | doEndTag()
Select the BEST case to use message-driven bean?(Choose one) | Need to avoid tying up server resources andneed the applications to process messages asynchronously
Which is NOT the role of EJB Deployer? | Write the code that calls on components supplied by bean providers
Which of the following method can be used to add cookies to a servlet response? | HttpServletResponse.addCookie(Cookie cookie)
What is output to the web page on the second access to the same instance of the following JSP? <html><body><% int x = 0; %><%= x++ %></body> </html> | 0
In EJB 2.0, ejb-jar.xml deployment descriptor file must be placed in ___________ folder. | META-INF
The page directive is used to convey information about the page to JSP container. Which statement is legal page directive. Select one correct statement | <%@ page info="test page" session="false"%>
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/Final/test.jsp?name=John. The test.jsp contains the following code.<% String myName=request.getParameter("name");%><% String test= "Welcome " + myName; %><%=test%>What is the output? | The page display "Welcome John"
What will happen when a servlet makes the following call within its doGet() method? getServletContext().setAttribute("userid", userid); | The userid attribute is placed in application scope.
Which of the following is true statement about the JavaServer Page life cycle?(Choose one) | The _jspService() method is called from the generated servlet�s service() method
Which is NOT the main type of JSP constructs that you embed in a page? | actions
Which statement(s) about Servlet Life Cycle is(are) correct? (Choose one) | All the others
_______________ sends a request to an object and includes the result in a JSP file | <jsp:include>
Which syntax is correct for JSP Declarations? | <%! code %>
Which statement is correct about Container-managed persistent (CMP)? | Container-managed persistent persisted by the Enterprise Java Beans container
Your jsp page uses classes from java.util package. Which of the following statement would allow you to import the package? (Choose one) | <%@ page import="java.util.*"%>
Which of the following is a valid standard action that can be used by a jsp page to import content generated by another JSP file named another.jsp? | <jsp:include page='another.jsp'/>
Which class that includes the getSession method that is used to get the HttpSession object? | HttpServletRequest
Which of the following statement correctly store an object associated with a name at a place where all the servlets/jsps of the same webapp participating in a session can access it? Assume that request, response, name, value etc. are references to objects of appropriate types.(Choose one) | request.getSession().setAttribute(name, value);
If a ______________is being used then all the operations need to be written by the developer to a persistent API. | Bean-Managed persistent entity bean
Which is the CORRECT statement? | Entity beans represent persistent state objects (things that don�t go away when the user goes away)
Study the statements:1) URL rewriting may be used when a browser is disabled cookies. 2) In URL encoding the session id is included as part of the URL. Which is the correct option? | Both 1 and 2 are true
A ___________________________ in EJB is an object that is deploy on any EJB Server | Component
You can set a page to be an error page either through web.xml or by adding a page directive _____ | <%@page errorPage="errorPage.jsp" %>
A ������.. manages the threading for the servlets and JSPs and provides the necessary interface with the Web server | Web Container
create() method of entity bean home interface returns _____________ | null
The _________________ is the overall application architect. This party is responsible for understanding how various components fit together and writes the applications that combine components | Application Assembler
Identify correct statement about a WAR file.(Choose one) | It contains web components such as servlets as well as EJBs
Which of the following statement is correct? (choose one) | Authorization means determining whether one has access to a particular resource or not.
A session bean being used by a client can also be used by another client. | False
Which of the following is example of JSP directive? Select one correct answer. | include
Which interface and method should be used to retrieve a servlet initialization parameter value? (Choose one) | ServletConfig : getInitParameter(String name)
Which is NOT the BEST case to use Enterprise Java Beans? (Choose one) | The applications are small or medium size.
Which of the following classes define the methods setStatus(...) and sendError(...) used to send an HTTP error back to the browser? | Both are defined in HttpServletResponse
Which is NOT EJB container? | Apache Tomcat 5.5
Which of the statements regarding the following code are correct? public void doPost(HttpServletRequestreq, HttpServletResponse res) throws IOException, ServletException{res.getWriter().print("Hello ");RequestDispatcherrd = getServletContext().getRequestDispatcher("/test.jsp");rd.include(req, res);res.getWriter().print("World");} | "Hello" and "World" both will be a part of the output.
Which statement is true? | When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page
A ____________ session bean is a bean that holds conversations that span a single method call. | stateless
Which of the following elements are used for error handling and are child elements of <web-app> of a deployment descriptor? | <error_page>
Message-driven beans do not have any return value. | True
Given the following deployment descriptor:<web-app> context-param><param-name>jdbcDriver</param-name><param-value>sun.jdbc.odbc.JdbcOdbcDriver</param-value></context-param><servlet><servlet-name>InitParams</servlet-name><servlet-class>InitParamsServlet</servlet-class></servlet> ..</web-app>What is the outcome of running the following servlet? (Choose one.)public class InitParamsServlet extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {ServletContextsc = this.getServletContext(); PrintWriter out = response.getWriter(); out.write("Initialization Parameter is: " + sc.getInitParameter("jdbcDriver")); }} | "Initialization Parameter is: null" returned to the requester
Consider the contents of 2 jsp files:<!-- In File : test.jsp --><html><body><% String s = "Hello"; %>//1 insert LOC here.<%=s%></body></html><!-- In File : test2.jsp --><% s = s+" world"; %>What can be inserted at //1 so that it prints "Hello world" when test.jsp is requested? | <jsp:include page="test2.jsp"/>
Which of the following is true about Data Integrity? | The information/data is not tampered with, in transit from host to client.
To be a servlet, a class should extend HttpServlet and override doGet or doPost, depending on whether the data is being sent by GET or by POST. | True
Name the default value of the scope attribute of <jsp:useBean> | page
The properties that characterize transactions are known as ACID properties. | True
In ejb-jar.xml file, <persistence-type> element value is _________________ | Bean or Container
Identify correct statement about a WAR file.(Choose one) | It contains web components such as servlets as well as EJBs.
Select the word to replace ???to make the diagram about messaging domain correct | Topic
A web application is located in "helloapp" directory. Which directory should it's deployment descriptor be in? | helloapp/WEB-INF
Which statement is correct about Message-Driven Beans exception handling? | Message-Driven Beans cannot send any exceptions back to clients
HTTP is a "stateless" protocol: each time a client retrieves a Web page, it opens a separate connection to the Web server, and the server does not automatically maintain contextual information about a client. | True
Which statement is correct about Bean-managed persistent (BMP)? | Bean-managed persistent persisted by the developer, who write the code for the database access calls
Regarding URL rewriting for session support, which of the following is true? | Every URL that the client uses must include jsessionid.
Which syntax is correct for JSP Scriptlets? | <% code %>
What is output to the web page on the second access to the same instance of the following JSP?<html><body><%! int x = 0; %><%= x++ %></body> </html> | 0
Which of these is legal return type of the doStartTag method defined in a class that extends TagSupport class? | EVAL_BODY
Select the correct JMS programming model. | Locate the JMS Driver->Create a JMS connection->Create a JMS session->Locate the JMS destination->Create a JMS producer or a JMS consumer->Send or receive message.
___________________ includes a static file in a JSP file, parsing the file's JSP elements | include directive
Which of the following JSP variable is not available within a JSP expression? Select one correct answer | httpsession
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select one correct answer. | SC_MOVED_TEMPORARILY
You do not want the user to see the data and the format being passed to your server when the user tries to submit the information for registering with your site. Which HTTP method would you use? (Comment: You can set some hidden parameters such as server location, in the page when the user loads it. Such parameters mean nothing to the user and are generally not displayed. However, determined users can still view them using "View Source" for the page). | POST
The ______________ supplies business components, or enterprise beans. | Bean provider
Which is the BEST case use Container-managed persistent (CMP)? | When you require some kind of special bean, like multi-tables, that cannot be completely realized with a single bean
Which statement is correct about Message-Driven Beans?(Choose one) | Message-Driven Beans stateless
Every method of the remote interface must throw a __________________ | RemoteException
Which of these is true about deployment descriptors? Select one correct answer | None of the others
The instantiation of a session bean is done by the ____________________ while the management of the lifetime of the bean is done by the ___________________________. | Container/EJB server
Which of the following code snippet of HTML document are correct structured? | <HTML><HEAD><TITLE>...</TITLE>...</HEAD><BODY ...>...</BODY></HTML>
What is the result of attempting to access the following JSP page?<html><body><%! public String methodA() { return methodB();}%><%! public String methodB() { return "JAD Final Test";}%><h2><%= methodA() %></h2></body></html> | "JAD Final Test" is output to the resulting web page
______and _______methods do not apply to stateless session beans. | ejbActivate() ejbPassivate()
A JavaBeans component has the following field | public void setEnabled( boolean enabled) public booleangetEnabled()
Which of the following is indicated by URL, which is used on the Internet? | Information resources(sources) on the Internet
You want to use a bean that is stored in com/enthu/GUI.ser file. Which of following statements correctly defines the tag that accesses the bean? | <jsp:useBean id="pref" beanName="com.enthu.GUI" type="com.enthu.GUI"/>
A JSP page has the following page directives:<%@page isErrorPage='false' %> <%@page errorPage='/jsp/myerror.jsp' %> Which of the following implicit object is NOT available to the jsp page? | exception
A bean with a property color is loaded using the following statement <jsp:useBean id="fruit" class="Fruit"/>Which of the following statements may be used to print the value of color property of the bean?. Select the one correct answer. | <jsp:getProperty name="fruit" property="color"/>
The ____________ interface is a Java interface that enumerates the business methods exposes by the enterprise bean class. | remote
A ____________ is a group of operations, which appear as one large operation during execution. | Transaction
Select the BEST case to Use Entity Beans? (Choose one) | At any given time, only one client has access to the bean instance.
Which are the types of messaging domains? (choose 2) | Publish/Subscribe Point-to-Point
Message-Driven Bean does not have a home interface, local home interface, remote interface, or a local interface. | True
For what reason does the following JSP fail to translate and compile? <html><body><%! int x; %><%=x ; %></body></html> | Error in JSP Expression
Which of the following statement is true about the Entity class? | Entity class must be declared as top level class
A bean with a property color is loaded using the following statement <jsp:useBean id="fruit" class="Fruit"/> Which statement may be used to set the color property of the bean | <jsp:setProperty name="fruit" property="color" value="white"/>
Which of the following xml fragments correctly define a security constraint in web.xml? (Choose one) | <security-constraint><web-resource-collection><web-resource-name>Info</web-resource-name><url-pattern>/info/*</url-pattern><http-method>GET</http-method></web-resource-collection><auth-constraint><role-name>manager</role-name></auth-constraint></security-constraint>
Study the statements about web.xml file: 1) The deployment descriptor file is called web.xml, and it must be located in the WEB-INF directory.2) web.xml is in XML (extended markup language) format. Its root element is <web>. | Only statement 1 is true
A JSP expression is used to insert values directly into the output. | True
A JSP page will not have access to session implicit variable if: | the session attribute of page directive is set to false
The ______________ is the container-generated implementation of the remote interface | EJB Object
Which of the following is NOT a valid attribute for a useBean tag? | className
What gets printed when the following JSP code is invoked in a browser? Select one correct answer. <%= if(Math.random() < 0.5) %> hello<%= } else { %> hi<%= } %> | The JSP file will not compile
Is it possible to share aHttpSession object between a Java Server Page and Enterprise Java Bean? | Yes, you can pass the HttpSession as parameter to an EJB method, only if all objects in session are serializable
Deployment properties are stored in a _______________________ file. | XML
Which is the correct sequence? | Jsp page is translated -->jsp page is complied-->jspInit is called ->_jspService is called -->jspDestroy is called
The HttpServletRequest has methods by which you can find out about incoming information such as: | All of the others
| primary key
JavaServer Pages (JSP) technology enables you to mix regular, static HTML with dynamically generated content from servlets. You simply write the regular HTML in the normal manner, using familiar Web-page-building tools | True
Which of the following is INCORRECT statement about implicit objects and scope? | application can't be used to access other web application resources
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element? Do not include the element in enclosing parenthesis | error-page
Which of the following is legal JSP syntax to print the value of i. Select the one correct answer | <%int i = 1;%> <%= i %>
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/test.jsp?name="John". The test.jsp contains the following code. <%! String myName=request.getParameter();%><% String test= "welcome" + myName; %><%= test%> | The program gives a syntax error because of the statement <%! String myName=request.getParameter();%>
Which of the following correctly represents the following JSP statement. Select the one correct answer. <%=x%> | <jsp:expression>x</jsp:expression>
Which of the following correctly represents the following JSP statement. Select the one correct answer. <%x=1;%> | <jsp:scriptlet>x=1;</jsp:scriptlet>
What gets printed when the following JSP code is invoked in a browser. Select the one correct answer. <%= if(Math.random() < 0.5) %> hello<%= } else { %> hi <%= } %> | The JSP file will not compile.
Which of the following are correct. Select the one correct answer | To use the character %> inside a scriptlet, you may use %\> instead.
What gets printed when the following is compiled. Select the one correct answer.<% int y = 0; %> <% int z = 0; %> <% for(int x=0;x<3;x++) { %> <% z++;++y;%> <% }%> <% if(z<y) {%> <%= z%> <% } else {%> <%= z - 1%> <% }%> | 2
Which of the following JSP variables are not available within a JSP expression. Select the one correct answer. | httpsession
A bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> Which of the following statements may be used to print the value of color property of the bean. Select the one correct answer | <jsp:getProperty name="fruit" property="color"/>
A bean with a property color is loaded using the following statement | <jsp:setProperty name="fruit" property="color" value="white"/>
A bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> What happens when the following statement is executed. Select the one correct answer. <jsp:setProperty name="fruit" property="*"/> | C. All the properties of the fruit bean are assigned the values of input parameters of the JSP page that have the same name
Which of the following represents a correct syntax for usebean. Select the two correct answers | <jsp:usebean id="fruit type ="String"/> <jsp:usebean id="fruit type ="String" beanName="Fruit"/>
Name the default value of the scope atribute of <jsp:usebean>. | page
Which of the following statements are true for <jsp:usebean>. Select the two correct answers. | The id attribute must be defined for <jsp:usebean>. The <jsp:usebean> must include either type or class attribute or both.
Which of these are legal attributes of page directive. Select the two correct answers | errorPage . session
Which of the following represents the XML equivalent of this statement <%@ include file="a.jsp"%> . Select the one correct statement | C. <jsp:directive.include file="a.jsp"/>
Assume that you need to write a JSP page that adds numbers from one to ten, and then print the output.<% int sum = 0;for(j = 0; j < 10; j++) { %>// XXX --- Add j to sum<% } %>// YYY --- Display the sum Which statement when placed at the location XXX can be used to compute the sum. Select the one correct statement | <% sum = sum + j; %>
Now consider the same JSP example as last question. What must be added at the location YYY to print the sum of ten numbers. Select the one correct statement | <%= sum %>
JSP pages have access to implicit objects that are exposed automatically. One such object that is available is request. The request object is an instance of which class? | HttpServletRequest
JSP pages have access to implicit objects that are exposed automatically. Name the implicit object that is of type HttpSession. | session
A Java bean with a property color is loaded using the following statement <jsp:usebean id="fruit" class="Fruit"/> What is the effect of the following statement. <jsp:setproperty name="fruit" property="color"/> Select the one correct answer. | If there is a non-null request parameter with name color, then its value gets assigned to color property of Java Bean fruit.
The page directive is used to convey information about the page to JSP container. Which of these are legal syntax of page directive. Select the two correct statement | <%@ page info="test page" session="false"%> <%@ page session="true" %>
Is the following JSP code legal? Select the one correct statement. <%@page info="test page" session="false"%> <%@page session="false"%> | No. This code will generate syntax errors
A JSP page uses the java.util.ArrayList class many times. Instead of referring the class by its complete package name each time, we want to just use ArrayList. Which attribute of page directive must be specified to achieve this. Select the one correct answer | import
A JSP page needs to generate an XML file. Which attribute of page directive may be used to specify that the JSP page is generating an XML file. | contentType
Which of these are true. Select the two correct answers | The default value of isThreadSafe attribute of page directive is true .When isThreadSafe attribute of page directive is set to true, a thread is created for each request for the page
Which of the following are examples of JSP directive. Select the two correct answers.(?)(not checked yet) | include, taglibrary, page
Which of these is true about include directive. Select the one correct answer | When using the include directive, the JSP container treats the file to be included as if it was part of the original file
Name the implicit variable available to JSP pages that may be used to access all the other implicit objects | pageContext
Which of the following files is the correct name and location of deployment descriptor of a web application. Assume that the web application is rooted at \doc-root. Select the one correct answer | C. \doc-root\WEB-INF\web.xml
Which element of the servlet element in the deployment descriptor is used to specify the parameters for the ServletConfig object. Select the one correct answer. | B. init-param
Which of these is true about deployment descriptors. Select the one correct answer | The order of elements in deployment descriptor is not important. The elements can follow any order
The exception-type element specifies an exception type and is used to handle exceptions generated from a servlet. Which element of the deployment descriptor includes the exception-type as a sub-element. Select the one correct answer | error-page
Which of these is a correct fragment within the web-app element of deployment descriptor. Select the one correct answer. | <error-page> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </error-page>
Which element of the deployment descriptor of a web application includes the welcome-file-list element as a subelement. Select the one correct answer.(?)(not checked yet) | welcome-file
Which of these is a correct fragment within the web-app element of deployment descriptor. Select the two correct answer | A.<error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page> D. <error-page> <exception-type>mypackage.MyException</exception-type> <location>/error.jsp</location> </error-page>
Which of these is a correct example of specifying a listener element resented by MyClass class. Assume myServlet element is defined correctly. Select the one correct answer | <listener> <listener-class>MyClass</listener-class></listener>
The root of the deployment descriptor is named as | web-app
With in a context-param element of deployment descriptor, which of the following element is required? | param-name
Which of these is not a valid top level element in web-app | param-name
Which of the follwing are mandatory elements within the filter element. Select two correct answers. | A.filter-name D.filter-class
Which of these is not a valid value for dispatcher element of filter-mapping. Select the one correct answer. | RESPONSE
Which of these is not correct about the filter-mapping element of web-app. Select the one correct answer | dispatcher element can be declared zero to three times in the filter-mapping element
When implementing a tag, if the tag just includes the body verbatim, or if it does not include the body, then the tag handler class must extend the BodyTagSupport class. Is this statement true of false. | false
Fill in the blanks. A tag handler class must implement the javax.servlet.jsp.tagext.Tag interface. This is accomplished by extending the class TagSupport or another class named in one of the options below. Select the one correct answer. | BodyTagSupport
Is this statement true or false. The deployment descriptor of a web application must have the name web.xml . In the same way the tag library descriptor file must be called taglib.xml | false
A JSP file that uses a tag library must declare the tag library first. The tag library is defined using the taglib directive - <%= taglib uri="..." prefix="..."%> Which of the following specifies the correct purpose of prefix attribute. Select the one correct answer. | The prefix attribute is used in front of a tagname of a tag defined within the tag library.
A JSP file uses a tag as <myTaglib:myTag>. The myTag element here should be defined in the tag library descriptor file in the tag element using which element. Select the one correct answer | name
Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers | A. tlib-version B.short-name
Which of the elements defined within the taglib element of taglib descriptor file are required. Select the two correct answers | A. name D.tag-class
Name the element within the tag element that defines the name of the class that implements the functionality of tag. Select the one correct answer | tag-class
Which of these are legal return types of the doStartTag method defined in a class that extends TagSupport class. Select the two correct answers | D.EVAL_BODY_INCLUDE (F.SKIP_BODY
Which of these are legal return types of the doAfterBody method defined in a class that extends TagSupport class. Select the two correct answers | D.EVAL_BODY_AGAIN (F.SKIP_BODY
Which of these are legal return types of the doEndTag method defined in a class that extends TagSupport class. Select the two correct answers. | A. EVAL_PAGE (E.SKIP_PAGE)
The method getWriter returns an object of type PrintWriter. This class has println methods to generate output. Which of these classes define the getWriter method? Select the one correct answer. | HttpServletResponse
Name the method defined in the HttpServletResponse class that may be used to set the content type. Select the one correct answer. | setContent
Which of the following statement is correct. Select the one correct answer | The HttpServletResponse defines constants like SC_NOT_FOUND that may be used as a parameter to setStatus method
The sendError method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter. Select the one correct answer | SC_NOT_FOUND
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with the following parameter and a Location header in the URL. Select the one correct answer | SC_MOVED_TEMPORARILY
Which of the following statements are correct about the status of the Http response. Select the one correct answer. | A status of 200 to 299 signifies that the request was successful.
To send binary output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | getOutputStream
To send text output in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. Select the one correct answer. | getWriter
Is the following statement true or false. URL rewriting may be used when a browser is disabled. In URL encoding the session id is included as part of the URL. | true
Which of the following are correct statements? Select the two correct answers | A.The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext C.The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method
A user types the URL http://www.javaprepare.com/scwd/index.html . Which HTTP request gets generated. Select the one correct answer | A. GET method
Which HTTP method gets invoked when a user clicks on a link? Select the one correct answer | GET method
When using HTML forms which of the folowing is true for POST method? Select the one correct answer. | POST method sends data in the body of the request.
Which of the following is not a valid HTTP/1.1 method. Select the one correct answer | COMPARE method
Name the http method used to send resources to the server. Select the one correct answer | B. PUT method
Name the http method that sends the same response as the request. Select the one correct answer | TRACE method
Which three digit error codes represent an error in request from client? Select the one correct answer | C. Codes starting from 400
Name the location of compiled class files within a war file? Select the one correct answer | /WEB-INF/classes
What gets printed when the following expression is evaluated? Select the one correct answer. ${(1==2) ? 4 : 5} | 5
What gets printed when the following expression is evaluated? Select the one correct answer. ${4 div 5} | 0.8
What gets printed when the following expression is evaluated? Select the one correct answer. ${12 % 4} | 0
What is the effect of executing the following JSP statement, assuming a class with name Employee exists in classes package. <%@ page import = "classes.Employee" %> <jsp:useBean id="employee" class="classes.Employee" scope="session"/> <jsp:setProperty name="employee" property="*"/> | The code sets the values of all properties of employee bean to matrching parameters in request object
What is the effect of evaluation of following expression? Select the one correct answer. ${(5*5) ne 25} | false
What is the effect of evaluation of following expression? Select the one correct answer. ${'cat' gt 'cap'} | true
How many numbers are printed, when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:forEach var="item" begin="0" end="10" step="2"> ${item} </c:forEach> | 6
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="item" value="2"/> <c:if test="${var==1}" var="result" scope="session"> <c:out value="${result}"/> </c:if> | Nothing gets printed.
What gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="item" value="2"/> <c:forEach var="item" begin="0" end="0" step="2"><c:out value="${item}" default="abc"/></c:forEach> | 0
How many numbers gets printed when the following JSTL code fragment is executed? Select the one correct answer.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="item" value="2"/> <c:choose> <c:when test="${item>0}"> <c:out value="1"/> </c:when> <c:when test="${item==2}"> <c:out value="2"/> </c:when> <c:when test="${item<2}"> <c:out value="3"/> </c:when> <c:otherwise> <c:out value="4"/> </c:otherwise> </c:choose> | One number gets printed.
Which numbers gets printed when the following JSTL code fragment is executed? Select the two correct answers. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="j" value="4,3,2,1"/> <c:forEach items="${j}" var="item" begin="1" end="2"> <c:out value="${item}" default="abc"/> </c:forEach> | 2 3
Which numbers gets printed when the following JSTL code fragment is executed? Select the two correct answers.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <c:set var="j" value="4,3,2,1"/> <c:forEach items="${j}" var="item" begin="1" end="2" varStatus="status"> <c:out value="${status.count}" default="abc"/> </c:forEach> | 2 3
Which number gets printed when the following JSTL code fragment is executed? Select the one correct answers.<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %><c:set var="j" value="4,3,2,1"/><c:forEach items="${j}" var="item" varStatus="status"><c:if test="${status.first}"><c:out value="${status.index}" default="abc"/></c:if></c:forEach> | 1
Which of these represent the correct path for the core JSTL library in JSTL version 1.1? Select the one correct answer | http://java.sun.com/jsp/jstl/core
Identify the method used to get an object available in a session.(Choose one) | a. getAttribute of HttpSession
See the extract from web.xml of web application "mywebapp" on server named myserver, runs on port 8080: <servlet-mapping><servlet-name>ServletA</servlet-name><url-pattern>/</url-pattern></servlet-mapping><servlet-mapping><servlet-name>ServletB</servlet-name><url-pattern>/bservlet.html</url-pattern></servlet-mapping><servlet-mapping><servlet-name>ServletC</servlet-name><url-pattern>*.servletC</url-pattern></servlet-mapping><servlet-mapping><servlet-name>ServletD</servlet-name><url-pattern>/dservlet/*</url-pattern></servlet-mapping>Given that a user enters the following into her browser, which (if any) of the mapped servlets will execute? (Choose one.) http://myserver:8080/mywebapp/Bservlet.html | a. ServletA
The HttpSession method getAttribute returns the object associated with a particular name. | a. True
Which method of ReportGeneratorServlet will be called when the user clicks on the URL shown by the following HTML. Assume that ReportGeneratorServlet does not override the service(HttpServletRequest, HttpServletResponse) method of the HttpServlet class. (Choose one) | a. doGet(HttpServletRequest, HttpServletResponse);
GET requests and POST requests can both be used to send form data to a web server. | a. True
Which statements are BEST describe id attribute of <jsp:useBean id=..... /> Action? | a. The name used to manipulate the Java object with actions <jsp:setProperty> and <jsp:getProperty>. A variable of this name is also declared for use in JSP scripting elements. The name specified here is case sensitive.
Which statement is true about both stateful and stateless session beans about bean instances? | a. Bean instances are NOT require to survive container crashes
Which of the elements defined within the taglib element of taglib descriptor file are required? Select one correct answer. | a. taglib-location
In which of the following Authentication mechanism, the browser transmits the username and password to the server without any encryption? (Choose one) | a. HTTP BASIC Authentication
Which of the following techniques would correctly put a bean into application scope? (You can assume that any necessary page directives are present and correct elsewhere in the JSP page.)(Choose one.) | a. <jsp:useBean id="app1" class="webcert.ch07.examp0701.AddressBean" scope="application" />
Which statement about JMS is true? | a. JMS supports Publish/Subcribe
Which is the CORRECT statement about JMS? | a. JMS uses JNDI to find destination
Which statements are BEST describe name attribute of <jsp:setProperty name=.... /> action? | a. The ID of the JavaBean for which a property (or properties) will be set.
Action _______has the ability to match request parameters to properties of the same name in a bean by specifying "*" for attribute property. | a. <jsp:setProperty>
Consider the following java code://in file Book.java package com.bookstore;public class Book{private long isbn; public Book(){ isbn = 0; }public long getIsbn(){ return isbn; }public void setIsbn(long value){ this.isbn = value; }}Code for browse.jsp:<jsp:useBean class="com.bookstore.Book" id="newbook" />LINE 1 : <jsp:setProperty name="newbook" property="isbn" value="1000"/> Which of the following statements are correct? | a. The isbn property of newbook will be set to 1000.
Which of the following is equivalent <%! ? (Choose one) | a. <jsp:declaration
<html><body><form action="loginPage.jsp">Login ID:<input type= "text" name="loginID"><br>Password:<input type="password" name="password"><br><input type="submit" value="Login"><input type="reset" value="Reset"></form></body><html> Study the above html code. Assume that user clicks button Reset. What is the correct statement? | a. All inputs are cleared.
JSP __________ let you insert arbitrary code into the servlet's _jspService method (which is called by service). | a. scriptlets
Which HTTP method is used in FORM based Authentication? | a. POST
Review the following scenario; then identify which security mechanisms would be important to fulfill the requirement. (Choose one.) An online magazine company wishes to protect part of its website content, to make that part available only to users who pay a monthly subscription. The company wants to keep client, network, and server processing overheads down: Theft of content is unlikely to be an issue, as is abuse of user IDs and passwords through network snooping. | a. Authorization and Authentication
Which class type must be implicitly or explicitly denoted in the persistence.xml descriptor as managed persistence classes to be included within a persistence unit? | a. Entity classes
Which option can be used to predefine Java Persistence queries for easy use? | a. @NamedQuery annotation
What is the implementation specification of EJB 3 session bean classes? | a. a session bean class must be marked with @Stateless or @Stateful
Which statement is true about management of an EJB's resources? | a. The reference to home object is obtained through JNDI to improve maintainability and flexibility.
Which is NOT belonging to basic three types of EJB? | a. Transfer object
Which act as a proxy to an EJB? | a. Remote instance
Which statement is true about EJB 3.0 stateful session beans and stateless session beans? (Choose one) | a. Both can have multiple remote and local business interfaces
Which statements are BEST describe property attribute of <jsp:setProperty property=.... /> Action? | a. The ID of the JavaBean for which a property (or properties) will be set.
Which statements are BEST describe errorPage attribute of <%@ page errorPage=....%> directive? | a. Any exceptions in the current page that are not caught are sent to the error page for processing. The error page implicit object exception references the original exception.
Which statements are BEST describe prefix attribute of <%@ taglib prefix=...%>directive of JSP file? | a. Specifies the relative or absolute URI of the tag library descriptor.
The following statement is true or false? "If the isThreadSafe attribute of the page directive is true, then the generated servlet implements the SingleThreadModel interface." | a. True
Study the statements:<question>1) The context path contains a special directory called WEB-INF, which contains the deployment descriptor file, web.xml.<question>2) A client application may directly access resources in WEB-INF or its subdirectories through HTTP. | a. Only statement 1 is true
A .................... manages the threading for the servlets and JSPs and provides the necessary interface with the Web server. | a. Web Container
What is the consequence of attempting to access the following JSP page? <question><html><question><body><question><%! <question> public void _jspService(HttpServletRequest request, HttpServletResponse response) {<question> out.write("A");<question> }<question> %><question><% out.write("B"); %><question></body><question></html> | a. Duplicate method compilation error.
A developer wants to achieve the following two behaviors for an EJB 3.0 session bean:(1) If the client calls a business method with a transaction context, the container will invoke the enterprise bean's method in the client's transaction context.(2) If the client calls a business method without a transaction context, the container will throw the javax.ejb.EJBTransactionRequiredException.Which transaction attribute should be used? | a. MANDATORY
Which statement is correct about Java EE client of a message-driven beans? | a. The client can use JNDI to obtain a reference to a message destination
________ is the well-known host name that refers to your own computer. | a. localhost
You have to send a gif image to the client as a response to a request. Which of the following calls will you have to make? (Choose one) | a. response.setContentType("image/gif");
The Java Persistent API defines the Query interface. Which statement is true about the Query.executeUpdate method ? | a. It must always be executed within a transaction
A JSP page called test.jsp is passed a parameter name in the URL using http://localhost/Final/test.jsp?name=John. The test.jsp contains the following code.<% String myName=request.getParameter("name");%><% String test= "Welcome " + myName; %><%=test%>What is the output? | a. The page display "Welcome John"
Which statement is NOT true about JMS? | a. JMS does NOT depend on MOM (Messaging-Oriented Middleware) products
To read the cookies that come back from the client, you call getCookies on the HttpServletRequest. | a. True
Given a stateless session bean with container-managed transaction demarcation, from which method can a developer access another enterprise bean? | a. business method from the business interface
Study the statements:1) The context path contains a special directory called WEB-INF, which contains the deployment descriptor file, web.xml. 2) A client application may directly access resources in WEB-INF or its subdirectories through HTTP. | a. Only statement 1 is true
Which is NOT a technique that can be used to implement 'sessions' if the client browser does not support cookies? | a. Using Http headers.
_________________ provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user. | a. Session management
Which statement is true about the EJB 3.0 stateful session beans? | a. Its conversational state is retained across method invocations and transactions
Which of the following methods can be used to add cookies to a servlet response? | a. HttpServletResponse.addCookie(Cookie cookie)
Given that a servlet has been mapped to /account/. Identity the HttpServletRequest methods that will return the /account segement for the URI: /myapp/account/. | b. getServletPath
What should be the return type of the method using @PrePassivate? | b. void
Which statements are BEST describe isErrorPage attribute of <%@ page isErrorPage=....%> directive? | b. Specifies if the current page is an error page that will be invoked in response to an error on another page. If the attribute value is true, the implicit object exception is created and references the original exception that occurred.
Which statements are BEST describe <jsp:include> Action? | b. Dynamically includes another resource in a JSP. As the JSP executes, the referenced resource is included and processed.
A stateful session bean must commit a transaction before a business method | b. False
Which security mechanism proves that data has not been tampered with during its transit through the network? | b. Data integrity
Which is disadvantage of using JEE (or J2EE) server-side technologies in a web-based application? | b. Complexity
Which statement describe about JMS is NOT true? | b. JMS enhances access to email services
Which statements are BEST describe page implicit object of jsp file? | b. This java.lang.Object object represents the this reference for the current JSP instance.
Which component can use a container-managed entity manager with an extended persistent context? | b. Only stateful session beans
The sendRedirect method defined in the HttpServlet class is equivalent to invoking the setStatus method with they following parameter and a Location header in the URL. Select one correct answer. | b. SC_MOVED_TEMPORARILY
Which is NOT provided by the EJB tier in a multitier JEE (J2EE) application? | b. XML Parsing
Which is true about the relationship "A keyboard has 101 keys"? | b. This is a one-to-may relationship
If you want to send an entity object as the pass by value through a remote interface, which of the following statements are valid? (Choose one) | b. @Entity public class Employees implements Serializable{...}
Which statement is correct about the Java Persistence API support for the SQL queries? | b. The result of a SQL query is not limited to entities
Which of the following lines of code are correct? | b. @Entity public class Employees{... }
What should be the return type of the method using @PrePassivate? | void
Can we use the annotation @PrePassivate for more than one method in a Entity bean? | No
An object with page scope exists in every JSP of a particular Web application. | False
Which statement describe about Message-Driven Beans is correct? (Choose one) | b. An EJB 3.0 message-driven beans can itself be the client of another message-driven beans
To send binary outptut in a response, the following method of HttpServletResponse may be used to get the appropriate Writer/Stream object. | b. getOutputStream
Which of the following defines the class name of a tag in a TLD? | b. tag-class
Which statements are BEST describe prefix attribute of <%@ taglib prefix=...%>directive of JSP file? | b. Specifies the required prefix that distinguishes custom tags from built-in tags. The prefix names jsp, jspx, java, javax, servlet, sun and sunw are reserved.
Which is true about RMI? | b. RMI allows objects to be send from one computer to another
Which Java technology provides a unified interface to multiple naming and directory services? | b. JNDI
Which is disadvantage of using JEE ( or J2EE) server-side technologies in a web-based application? | b. Complexity
Which of the following correctly represents the following JSP statement? Select one correct answer. <%=x%> | b. <jsp:expression>x</jsp:expression>
Which of these is a correct fragment within the web-app element of deployment descriptor? Select the one correct answer | b. <error-page> <exception-type> mypackage.MyException</exception-type> <location> /error.jsp</location> </error-page>
Which is NOT represented in a UML class diagram? | c. The interaction between objects in sequential order
Which type of JEE (or J2EE) component is used to store business data persistently? | c. Entity Bean
The requirement for an online shopping application are: It must support millions of customers. The invocations must be transactional. The shopping cart must be persistent. Which technology is required to support these requirements? | c. EJB
Which statement is true about the use of a persist operation in a transaction of an Entity Beans | c. If a user persists a new entity with an existing primary key the transaction will fail
EJB 3.0 specifications are first implemented in ________ | c. Java EE 5
A developer must implement a "shopping cart" object for a web-based application. The shopping cart must be able to maintain the state of the cart, but the state is not stored persistently. Which JEE (J2EE) technology is suited to this goal? | c. Stateful session beans
What do you need to create a EJB3 session bean? | c. Annotate the session bean with @Stateful or @Stateless
A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB 3.0 session beans need to access this business logic. Which design approach can achieve this requirement? | c. No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.
Following is the code for doGet() and doPost() method of TestServlet. Which of the statement is correct? image | c. This will work for HTTP GET as well as POST requests.
Which is a valid PostConstruct method in a message-driven bean class? | c. @PostConstruct private void init() {}
Which statements are BEST describe taglib directive of JSP file? | c. Allows programmers to include their own new tags in the form of tag libraries. These libraries can be used to encapsulate functionality and simplify the coding of a JSP.
Which of the following are valid iteration mechanisms in jsp? | c. <% int i = 0;for(;i<5; i++){ %>"Hello World";<% i++;}%>
Which of the following constitute valid ways of importing Java classes into JSP page source? | c. <%@ page import="java.util.*" %>
What is the purpose of JNDI? | d. To access various directory services using a single interface
A Java programmer wants to develop a browser-based multitier application for a large bank. Which Java edition (or editions) should be used to develop this system? | d. J2SE and J2EE
Which is NOT responsibility of the business tier in a multitier web-based application with web, business, and EIS tiers? | d. To generate dynamic content
Which is NOT associated with the web tier in a JEE (J2EE) web-based application? | d. Message-driven beans
Which technology is used for processing HTTP requests and mapping those requests to business objects | d. Servlets
What would be the best directory in which to store a supporting JAR file for a web application? Note that in the list below, all directories begin from the context root. | d. \WEB-INF\lib
A developer is working on a user registration application using EJB 3.0. A business method registerUser in stateless session bean RegistrationBean performs the user registration. The registerUser method executes in a transaction context started by the client. If some invalid user data causes the registration to fail, the client invokes registerUser again with corrected data using the same transaction. Which design can meet this requirement? | d. Create an application exception with the rollback attribute set to false and have registerUser method throw it after registration fails.
Which of the following is correct? Select one correct answer | d. To use the character %> inside a scriptlet, you may use %\> instead.
Which of the following is NOT a standard technique for providing a sense of "state" to HTTP? | d. HTTP is already a stateful protocol.
Which statements are BEST describe response implicit object of jsp file? | d. This object represents the response to the client. The object normally is an instance of a class that implements HttpServletResponse (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a class that implements javax.servlet.ServletResponse.
Which of the following method calls can be used to retrieve an object from the session that was stored using the name "userid"? | d. getAttribute("userid");
Identify the method used to get an object available in a session. (Choose one) | d. getAttribute of HttpSession
A developer wants to use the Java Persistence query language. Which statement is true? | d. The WHERE clause is used to restrict the contents of a collection of objects that are returned from a query.
A developer wants to create a Java Persistence query that returns valid US phone numbers (formatted as 123-456-7890) from a collection of differently formatted international phone numbers. The developer needs only those numbers that begin with 303. Which WHERE clause is correct? | d. WHERE addr.phone LIKE '303-___-____'
Which of these is true about include directive? Select the one correct answer. | d. When using the include directive, the JSP container treats the file to be included as if it was part of the original file.
Which statements are BEST describe request implicit object of jsp file? | e. This object represents the client request. The object normally is an instance of a class that implements HttpServletRequest (package javax.servlet.http). If a protocol other than HTTP is used, this object is an instance of a subclass of javax.servlet.ServletRequest.
Which is NOT a scope of implicit objects of JSP file? | e. response
Which is NOT a state in the EJB 3 Entity beans life cycle states? | e. Exit
Which of the following JSP variable is not available within a JSP expression? Select one correct answer | e. httpsession
Classes HttpServlet and GenericServlet implement the___ interface. | c.Servlet