Servlet MCQ
Servlet MCQ
Which object is created by the web container at time of deploying the project?
a. ServletConfig b. ServletContext c. Both A & B d. None of the above
Which of the following code is used to get an attribute in a HTTP Session object in servlets?
A. session.getAttribute(String name)
B. session.alterAttribute(String name)
C. session.updateAttribute(String name)
D. session.setAttribute(String name)
Which method is used to specify before any lines that uses the PintWriter?
A. setPageType()
B. setContextType()
C. setContentType()
D. setResponseType()
A. Lifecycle management
B. Communication support
C. Multithreading support
What is bytecode?
A. Machine-specific code
B. Java code
C. Machine-independent code
Which object of HttpSession can be used to view and manipulate information about a session?
A. session identifier
B. creation time
D. Servlets execute within the address space of web server, platform independent and uses the
functionality of java class libraries
Which of the following statements are correct about the status of the Http response.
Which JDBC driver Type(s) can be used in either applet or servlet code?
D. Type 4 only
Which of the following code retrieves the MIME type of the body of the request?
A. new MimeType()
B. request.getContentType()
C. response.getContentType()
Which methods are used to bind the objects on HttpSession instance and get the objects?
A. setAttribute
B. getAttribute
C. Both A & B
To send text output in a response, the following method of HttpServletResponse may be used to
get the appropriate Writer/Stream object.
A. getStream
B. getOutputStream
C. getBinaryStream
D. getWriter
A. sendRedirect
B. forward
C. Both
D. None
B. to include an image
A. 1,2,3,4
B. 1,2
C. 1,3,4
D. 1,4
C. Add a new header and value or add an additional value to exiting header
A. servlet context
B. servlet container
A. goGet
B. doOption
C. doTrace
D. doPost
Setup() method
Constructor function
Initialization and Constructor function
Initialization