Page: 6
Unit-1: The Servlet Technology Model
Q26. Which statements about the servlet lifecycle methods are true? [Select all correct answers] - The init( ) method is called for every client request
- Since GET is the default HTTP method, HttpServlets.doGet( )method is calld even for other request types like POST, OPTIONS etc.
- The HttpServlets.doConnect( ) is empty implementation method.
- The destroy( ) method is guaranteed to be called only after any request processing.
- The service( )-doGet( )/( )do post( ) sequence is called for each request
. Q27. Which of the following Servlet API interfaces provide utility methods for sending text Or a binary stream to a client? [Select one correct answer] A. ServletContext B.SevletRequest C.HttpServletRequest D.ServletResponse E.servlet Q28. Consider the following URL: http://www.tatamcgrawhill.com/servlet/UserInputServlet?name=kuna Which method gets the value of name request parameter? [ Select all correct answers] - ServletRequest.getParameter(“name”);
- ServletRequest.getInitParameter(“kunal”);
- ServletsRequest.getParameterNames( )
- ServletRequest.getInitParameterNames( )
- ServletConfig.getInitParameter(“name”);
Q29. Which of the following methods would you use to retrieve request headers? [ Select all correct answer] - ServletRequest.getHeader(String HeaderName) B. HttpServeletsRequest.getHeader(String headerName)
- ServletRequest.getParameterNames( )
- HttpServletReequest.getHeaderValues(string headerName)
- HttpServletReequest.getIntHeader(string headerName)
Q30. Assume that you want to send a video file to users over the Web. Which class/interface And method combination would you use to send the video? [Select one correct answer] A. HttpServletResponse.getVideoStream( ) B. HttpServletResponse.getWriter( ) C. ServletRequest.getBinaryStream( ) D.HttpServletRequest.getOutputStream( ) E.ServeletResponse.getOutputStream( ) Q31. Consider the following code fragment taken from a servlet: Public void doGet(httpServletRequest request, HttpServletResponse response) throws ServletExceptions, IOException { Response. setContentType(“text/html”); PrintWriter out= response.getWriter( ); out.println<B> McGraw-Hill Education eBookshop</B>”); out.fluesh( ); Response. sendRedirect (request.getQueryString( )); } What will be the result of compiling and running above code snippet? [Select one correct answer] - It’ll fail to compile because there’s no sendRedirect( ) method in
HttpServletResponse. B. Compilation error because HttpServletResponse.sendRdirect( ) method accepts a URL. - An IllegalStateException will be thrown at runtime.
- No compilation error and successful output of “McGraw-Hill Education
eBookshop” in the browser window. E. No compilation error, but the browser will render a blank window.
Get Answers For All Questions
Page: 6
1
2
3
4
5
6
7
8
9
|