JAVA WEB 1

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

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 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

which are ejb containers? (choose three)

a. jboss b. ibm websphere c. bea's weblogic

for what reason does the following jsp fail to translate and compile?<html><body><%!intx%><%=x;%></body></html>

error in jsp expression

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

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

in ejb2.0, ejb-jar.xml deployment descriptor file must be placed in ______________folder

meta-inf

ejbcreate() method of entuty bean class returns ________________

primary key

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

a ______________ session bean is a bean that holds conversations that span a single method call

stateless

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

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

what is the minimum number of attributes that must be specified in the <c:foreach> action? (choose one.)

1-items

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

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'); %>

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' %>

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 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>

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>

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>

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 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 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>

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>

what is the parent tag for <welcome-file-list>? (choose one.)

<web-app>

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>

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

from the following list, what is a probable outcome from a call to the servletcontext.getattributenames() method? (choose one.)

a nonempty enumeration is returned

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

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

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

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 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

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 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

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>

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 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>

which of the following lines of code are correct

a. @entity public class employees{..}

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

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

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 valid servlet methods that match up with http methods? (choose four.)

a. doget() b. dopost() c. dooptions() d. dohead()

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 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

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

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

which of the following methods can be used to add cookies to a servlet reponse

a. httpservletresponse.addcookie(cookie cookie)

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 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

which of the http methods below is not considered to be 'oeidempotent'? (choose one.)

a. post

javabeans component has the following field:

a. public void set enabled(boolean enabled) public boolean getenabled()

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);

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

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)

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()

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

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

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

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

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

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

which security mechanism limits access to the availability of resources to permitted groups of users or programs? (choose one.)

authorization

in ejb-jar.xml file. <persistence-type> element value is ________________

bean or container

the _________________ supplies business components, of enterprise beans

bean provider

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

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 *.*

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

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 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

identify the two equivalent method calls in the list below. (choose two.)

httpservletrequest.getsession(). httpservletrequest.getsession(true)

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 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 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

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 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

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

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

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

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

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 ; it is illegal to have attributes of the same name existing in more than one scope

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 are implicit variables in el? (choose two.)

param. paramvalues

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

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 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 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

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

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

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

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

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

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

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

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

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()

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()

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 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

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


Ensembles d'études connexes

1601 Acid/Base balance adaptive quizing

View Set

Ch 22 Drugs for Alzheimer's Disease

View Set

sociology of health and illness exam 3 quiz answers

View Set

PrepU Chapter 24: Aspesis and Infection Control

View Set