WCD1题库Word下载.docx
《WCD1题库Word下载.docx》由会员分享,可在线阅读,更多相关《WCD1题库Word下载.docx(21页珍藏版)》请在冰豆网上搜索。
B.Viewelement
C.Controllerelement
D.Acombinationoftheseelements
4.Mandyneedstodesignawebapplicationforhisorganization.HedecidestousetheservletinthewebapplicationtorespondtoanHTTPrequestfromtheclient.Hefirstcreatesaform,create_form.do,toacceptinputfromtheuser.Heneedstomakesurethatwhentheuserselectsthesubmitbuttonontheform,thedatatobesenttoserveriscontainedinthebodyoftheHTTPrequest.Whichofthefollowingcodeshouldheuseintheformtoaccomplishthistask?
A.<
formaction=’create_form.do’method=’POST’>
B.<
formaction=’create_form.do’method=’GET’>
C.<
formmethod=’create_form.do’action=’POST’>
D.<
formmethod=’create_form.do’action=’GET’>
5Mandyneedstodesignawebapplicationforhisorganization.HedecidestousetheservletinthewebapplicationtorespondtoanHTTPrequestfromtheclient.Hefirstcreatesaform,create_form.do,toacceptinputfromtheuser.Heneedstomakesurethatwhentheuserselectsthesubmitbuttonontheform,thedatatobesenttoserveriscontainedintheURLoftheHTTPrequest.Whichofthefollowingcodeshouldheuseintheformtoaccomplishthistask?
formaction='
create_form.do'
method='
POST'
>
GET'
formmethod='
action='
6WhichofthefollowingHTTPmethodsisreservedforusewithaproxythatcanswitchtobeingatunnel?
A.HEAD
B.OPTIONS
C.TRACE
D.CONNECT
7WhichofthefollowingHTTPmethodsrequestfortheservertostoretheentityenclosedinthebodyoftheHTTPmessage?
D.PUT
8Youareworkingonanapplicationthathasmultiplecomponents.Thecontrolneedstransferredfromonecomponenttoanothercomponent.Theinvokingcomponentshouldnotbeabletoproduceanyoutputofitsown.WhichmethodfromtheRequestDispatcherinterfacecanbeusedtoperformthetask?
A.request
B.include
C.response
D.forward
9Considerthefollowingcodesnippet:
CodeforUserInterface:
<
html>
head>
/head>
body>
formmethod=“post”action=”/Servlet/validate”>
Login:
inputtype=”text”name=”t1”>
Password:
inputtype=”text”name=”t2”>
inputtype=“submit”value=“Submit”>
/form>
/body>
/html>
CodeforServlet:
importjavax.servlet.*;
importjavax.servlet.http.*;
importjava.io.*;
publicclassvalidateextendsHttpServlet
{
publicvoiddoPost(HttpServletRequestreq,HttpServletResponseres)
ThrowsServletException,IOException
res.setContentType(“text/html”);
PrintWriterout=res.getAWriter();
Stringz1=req.getParameter(“t1”);
Stringz2=req.getParameter(“t2”);
out.println(“<
”);
if(z1.equals(“User1”))
if(z2.equals(“password”))
{
out.println(“Welcometothewebsite”);
}
else
out.println(“InvalidPssword”);
out.println(“NoSuchuser”);
}
Whatwillbetheoutputoftheabovecode,ifusernameasUSER1andPasswordaspassword?
A.Welcometothewebsite.
B.InvalidPassword.
C.NosuchUser.
D.Thecodewillnotcompilesuccessfully.
10Whichofthefollowingistheruntimerepresentationofthewebapplication?
A.init
B.service
C.ServletContext
D.Servlet
11WhichofthefollowingisissuedauniquerequestandresponseobjectbythewebcontainerforeachHTTPrequestmappedtoagivenservlet?
12.YouhavecreatedtheAddLeagueFormservletthatincludesasingleinitializationparametercalledseasons-listwiththevalueSpring,Summer,Autumn,Winter.Thisconfigurationobjectispassedtotheservletinstancebywayoftheinitmethod,whichissentbythewebcontainer.Howwillyouwritethecodeintheweb.xmlfiletoinitializetheseasons-listparameterwiththerequiredvalues?
servlet>
<
servlet-name>
AddLeagueForm<
/servlet-name>
servlet-class>
sl314.view.AddLeagueFormServlet<
/servlet-class>
param-name>
season-list<
/param-name>
param-value>
Spring,Summer,Autumn,Winter<
/param-value>
/init-param>
/servlet>
classes.sl314.view.AddLeagueFormServlet<
init-param>
13.You,beingasoftwaredeveloper,needstodevelopawebapplicationforyourorganization.Youdecidedtouseservletstocreatethewebapplication.Youcreatedaform,AddEmpFormServlet.javatoaddthedetailsofthenewemployeesandcompiledit.Theclassfileisstoredunderthe/WEB-INF/classes/viewdirectory.Thedeploymentdescriptorfile,web.xml,storesthedefinitionoftheservlet,AddEmpFormServlet.Whatcodeshouldbewrittenintheweb.xmlfiletodefineAddEnpFormServletinit?
AddEmpForm<
view.AddEmpFormServlet<
AddEmpFormServlet<
14.Youarecreatingawebapplicationusingservlets.Theapplicationrequiresthatapplication-specificdataissharedacrossindependentwebcomponents.Whichobjectcanbeusedtoimplementthis?
A.Servlet
B.ServletConfig
D.ServletContextListener
14Youarecreatingawebapplicationusingservlets.Youneedtoensurethatsharedapplicationdatamustbein-memorybeforeanyHTTPrequestsareexecutedonthewebapplication.Whichobjectcanbeusedtoperformthisinitialization?
15JamesisdevelopingawebapplicationusingStrutsframework.Forthis,heneedstoconfigurealloftheapplication-specificclassesinthestruts-config.xmlfile.Whichofthefollowingtaginthisfileconfiguresthesetofviewmappingbetweenthesymbolicnameoftheviewtothelogicalpathtotheview?
A.action-mappings
B.forword
C.action
D.struts-config
15WhiledevelopingawebapplicationusingStruts,youneedtocreateaStructscontroller.Forthis,youarerequiredtoextendtheStrutsActionbaseandimplementtheexecutemethod.WhichofthefollowingisthesecondargumentoftheexecutemethodandissuppliedbyStruts?
A.ActionMapping
B.ActionForword
C.ActionForm
D.Action
15WhiledevelopingawebapplicationusingStruts,youneedtocreateaStructscontroller.Forthis,youarerequiredtoextendtheStrutsActionbaseandimplementtheexecutemethod.Whichofthefollowingisthesecondargumentoftheexecutemethodandissuppliedbythewebcontainer?
C.HttpServletRequest
D.HttpServletResponse
16Whichofthefollowingtagisusedtospecifytheinitializationparametersintheweb.xmlfile?
A.init-param
B.servlet
C.servlet-mapping
D.url-pattern
17WhichofthefollowingtagisNOTapartoftheweb.xmlfile?
A.servlet
B.action
C.param-name
D.param-value
18WhiledevelopingawebapplicationusingStruts,youconfiguredStrutsActionServletintheweb.xmldeploymentdescriptor.TheActionServletusesaninitializationparameter,calledconfig,tospecifythepathtotheStrutsconfigurationfile.Forthis,thefollowingcodeintheweb.xmlfile:
/WEB-INF/struts-config.xml<
However,thereanerrorinthecode,Identifytheerrorandprovidethecorrectcode?
config<
/WEB-INF<
19.WhiledevelopingawebapplicationusingStruts,youarerequiredtoconfiguretheStrutsconfigurationfile,struts-config.xml.Youhavetodeclaretwoforwardentries,successanderrorwithinthe/admin/add_leagueaction.Forthispurpose,thefollowingcodeinthestruts-config.xmlfile:
action-mappings>
actionpath=”/admin/add_league”type=”s1314.contorller.AddLeagueAction”>
forwardname=”error”path=”/admin/add_league.view”/>