JSP Servlet MCQs with answers Page - 2

You will find multiple-choice questions (MCQs) related to #JSP Servlet here. Go through these questions to prepare effectively for your upcoming exams and interviews.

To view the correct answer for any question, simply click the "Show Answer" button.

Have a question to share? Click on "Add Question" to contribute!

S

Satya • 3.38K Points
Extraordinary

Q. Which method is used to write output in a servlet?

  • (A) System.out.println()
  • (B) response.getWriter()
  • (C) request.getParameter()
  • (D) context.write()

S

Satya • 3.38K Points
Extraordinary

Q. Which configuration file defines servlet mapping?

  • (A) config.xml
  • (B) web.xml
  • (C) servlet.xml
  • (D) server.xml

S

Satya • 3.38K Points
Extraordinary

Q. Which annotation is used instead of web.xml mapping?

  • (A) @Servlet
  • (B) @WebServlet
  • (C) @ServletMapping
  • (D) @Mapping

S

Satya • 3.38K Points
Extraordinary

Q. Which object represents application-wide data?

  • (A) ServletConfig
  • (B) ServletContext
  • (C) HttpSession
  • (D) RequestDispatcher

S

Satya • 3.38K Points
Extraordinary

Q. Which object represents a user's session?

  • (A) ServletContext
  • (B) HttpSession
  • (C) ServletConfig
  • (D) Request

S

Satya • 3.38K Points
Extraordinary

Q. Which method retrieves form data in a servlet?

  • (A) getData()
  • (B) getParameter()
  • (C) readInput()
  • (D) fetchValue()

S

Satya • 3.38K Points
Extraordinary

Q. Which interface defines the servlet lifecycle methods?

  • (A) HttpServlet
  • (B) Servlet
  • (C) GenericServlet
  • (D) ServletContext

S

Satya • 3.38K Points
Extraordinary

Q. Which method handles all request types in HttpServlet?

  • (A) service()
  • (B) init()
  • (C) destroy()
  • (D) handle()

S

Satya • 3.38K Points
Extraordinary

Q. Which object is used to forward a request to another resource?

  • (A) HttpSession
  • (B) RequestDispatcher
  • (C) ServletContext
  • (D) ServletConfig

S

Satya • 3.38K Points
Extraordinary

Q. Which method redirects the client to another URL?

  • (A) forward()
  • (B) include()
  • (C) sendRedirect()
  • (D) dispatch()
What's Tag

As you may know, questions are organized under broad categories. Each category can include various types of questions. For example, the "History" category might contain questions about the Revolt of 1857, Shivaji Maharaj, Ancient History, Buddhism, and more.

To further refine this organization, we've introduced tags, which act as sub-categories to group questions more specifically.

Verified users can add tags to any question. If you have any suggestions regarding this system, we'd love to hear from you. Contact Us

Learn More