Skip to main content

Upwork/oDesk JSP 2.0 Test Answers

1. If cookies are turned off on the client, which two methods still work with the session ID?
 Answers: • encodeRedirectURL() or • sessionRedirectURL() or • encodeURL()

 2. Which two of the following statements are best associated with the HTTPPOST method?
 Answers: • There is no limit on how much data this HTTP method can send or • This method is most often used to submit form data

 3. Which two statements among the following apply to redirecting a HTTP request to another URL?
 Answers: • The path must be relative or • The redirect method must be called before the response body is committed, otherwise an IllegalStateException is thrown

 4. Which of the following statements are true regarding the HTTP GET method?
 Answers: • There is a limit on how much data this HTTP method can send or • This HTTP method is the fastest

 5. Which of the following statements are true regarding declaring a servlet instance in a deployment descriptor?
 Answers: • The tags are nested within <web-app> tags or • It specifies the fully qualified class name of the servlet

 6. Which of the following statements are true regarding the structure of a WebArchive file?
 Answers: • It has a war extension or • It is extracted by the container upon the first call to any�servlet it contains

 7. With regard to the service() lifecycle method, identify two correct statements about its purpose or about how and when it is invoked.
 Answers: • It is called whenever the servlet is requested or • It is called after the init method is called

 8. Read the following code snippet and answer the question based upon it:

 <taglib>
 <taglib-uri>
 http://www.yourcompany.com/you TagLibrary
 </taglib-uri>
 <taglib-location>
 /WEB-INF/yourTagLibrary.tld
 </taglib-location>
 </taglib>

 From the statements given below, which one applies to the code snippet?
 Answers: • The taglib directive can reference a TLD by name

 9. Which method is called by the servlet container just after the servlet is removed from service?
 Answers: • public void destroy() {// code...}


 10. Which statement is true regarding ServletContext Initialization Parameters in the deployment descriptor?
 Answers: • They are accessible by all servlets in a given container

 11. Which method in the HttpServlet class corresponds to the HTTPPOST method?
 Answers: • doPost

 12. What is the file name of the WebApp deployment descriptor?
 Answers: • web.xml

 13. What is the WebApp deployment descriptor element name for the Servlet Context Initialization Parameters?
 Answers: • <init-param>

 14. With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.
 Answers: • It gives the servlet an opportunity to clean up resources

 15. How would you use a bean in a JSP page?
 Answers: • <jsp:useBean id="houseLotBean" scope="session" class="session.Realestate"/>

 16. Which of the following is the name of the cookie used by Servlet Containers to maintain
 session information?
 Answers: • JSESSIONID

 17. Which design pattern reduces network traffic by acting as a caching proxy of a remote object?
 Answers: • Value Object

 18. Assuming the tag library is in place and the tag handler is correct, which of the following is the correct way to use a custom tag in a JSP page?
 Answers: • <yourLibrary:whatColorlslt color="red"/>

 19. What output will be sent to the browser by the following code snippet?

 <!--
 Que <%="Reader"%>
 -->
 Answers: • This is a comment so it is ignored by the container

 20. Which of the following are used by Servlet Containers to maintain session information?
 Answers: • URL rewriting

 21. Read the following code snippet:

 1 <libraryPrefix:handlerName parameterNAme="value">
 2 <%=23*counter %>
 3 <b>Congratulations!</b>

 Which of the following is the correct way to complete the above code snippet?
 Answers: • </libraryPrefix:handlerName>

 22. In which directory do you place any auxiliary JAR files?
 Answers: • WEB-INF/jar

 23. Which statements are true regarding ServletContext Init Parameters in the deployment descriptor?
 Answers: • They are set at deployment-time and can be updated at run-time

 24. With regard to the servlet context listener, which of the following methods is valid?
 Answers: • contextListenerInitialized

 25. Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how do you get a request parameter in that servlet?
 Answers: • String value=req.getParameter("product");

 26. Assume the custom tag is GLOOP and the prefix is TWONG. Which of the following is the syntax for an empty custom tag?
 Answers: • <TWONG:GLOOP/>

 27. Which of the following is not a JSP implicit object?
 Answers: • in

 28. Which of the following is the listener interface for servlet context attributes?
 Answers: • ServletContextListener

 29. What is Template Data?
 Answers: • The plain text (such as HTML) outside JSP tags(non java) in a JSP page

 30. Which of the following options is a valid declaration?
 Answers: • <%! String name="Patricia" %>

 31. Which of following interfaces can make a servlet thread safe?
 Answers: • synchronization

 32. Which statement is true regarding a servlet context listener?
 Answers: • An object that implements a context listener is notified when its Web App context is created or destroyed

 33. Which of the following options is a valid expression?
 Answers: • <%=(new java.util.Date()).toLocaleString() %>

 34. What does the container do with the following code snippet?

 <!--#include file="somefile.html"-->
 Answers: • The container passes this line of code through to the client

 35. Which method in the HttpServlet class corresponds to the HTTPPUT method?
 Answers: • put

 36. Which of the following is a JSP implicit object?
 Answers: • request

 37. Which design pattern is used to decouple presentation from core data access functionality?
 Answers: • DataAccess Object

 38. In which directory do you place servlet class files?
 Answers: • WEB-INF\classes

 39. Which design pattern did technical designers of JSP use to provide centralized dispatching of requests via a controller servlet?
 Answers: • Model-view-Controller

 40. Which interface and method name should be used to retrieve HTTP request header information?
 Answers: • HttpServletRequest.getHeaderNames

 41. Which interface provides access to request scoped attributes?
 Answers: • ServletContext

 42. Which JSP action retrieves the value of a property from a properly declared JavaBean in a JSP page?
 Answers: • jsp:getProperty

 43. Suppose you had a servlet that simply returned an error message because that resource was forbidden to that user. Read the following code snippet:

 1.public void service(HttpServletRequestrequest,
 2.HttpServletResponseresponse)
 3.throws ServletException, IOException
 4. {
 5.
 6. }

 What code would you type on line 5 to return an error message to the requesting client?
 Answers: • response.sendError(HTTPServletResponse.SC_FORBIDDEN,"Error");

 44. Which interface and method name should be used to acquire a text stream for the response?
 Answers: • ServletResponse.getOutputStream

 45. Which among the following objects is the best choice to share information between pages for a single user?
 Answers: • request

Comments

Popular posts from this blog

How to Choose Best Digital Marketing Engineer for your Business ?

Digital Marketing is new marketing concept of products, services and others using digital technologies on the internet. Previously we know digital marketing interms of internet marketing or online marketing. Digital marketing campaign is run on all the platform like; Desktop, tablet, mobile etc. Digital Marketing functions are SEO(search engine optimization), SEM(search engine marketing), Content Marketing, campaign marketing, e-commerce marketing, SMM(social media marketing), SMO(social media optimization), E-mail marketing, display advertising, games, ASO(Apps store optimization), Bulk SMS, branding, reputation management and other digital marketing platform techniques. If we can talk about simple SEO executive role, PPC Analyst role, SMO expert role or other single task handler then its a single activity performer. But if we hire a digital marketing engineer then its necessary that he has knowledge and working ability of all above digital marketing techniques. Simply we

Top SEO Companies in India by TOPSEO's Ranking

I am providing you the list of top 10 SEO Companies/Firms/Agencies in India by TOPSEO's  (January 2016) 1. SEO.IN  Year Founded: 2002 Website: http://www.seo.in / 2. SEOValley Solutions Private Limited Year Founded: 2000 Website: http://www.seovalley.com / 3. PageTraffic Year Founded: 2002 Website: http://www.pagetraffic.com/ 4. SeoTonic Web Solutions Private Ltd. Year Founded: 2006 Website: http://www.seotonic.com/ 5. Outsource SEO Year Founded: 2004 Website: http://www.outsourceseo.com/ 6. Ranking By SEO Year Founded: 2008 Website: http://www.rankingbyseo.com/ 7. Techmagnate Year Founded: 2006 Website: http://www.techmagnate.com / 8. SEO Discovery Year Founded: 2006 Website: http://www.seodiscovery.com/ 9. Greenlemon Year Founded: 1999 Website: http://greenlemon.in/ 10. SEOXperts India Year Founded: 2008 Website: http://www.seoxpertsindia.com/

Vivo IPL(10) 2017 Schedule , Player List , Team And Venue Details

IPL (10) 2017 Schedule is yet to be announced by the governing council of the Indian premier League . As per the previous sessions of the IPL it might also schedule to start from April 2017 to May 2017 . This session of IPL will also known as the Vivo Ipl (10)2017 because Vivo Electronics got the title sponsorship to 2 year after Pepsi terminated the contract back in 2016 . Like last year former IPL champions Chennai Super Kings and Rajasthan Royal will not participate the the tournament till this year . As per the schedule set by the IPL Committee, the Indian Premier League 2017 would be starting from 3rd of April and continue till 26th of May 2017. The first match of IPL 10 will have the IPL 5 winner Kolkata Knight Riders battling against Delhi Daredevils. The inaugural match as well as the final match of the IPL season 10 championship scheduled for 26th of May would be hosted by Eden Gardens, the home ground for superstar Shah Rukh Khan owned Kolkata Knight Riders. There wou