Java JSP (Java Server Pages) MCQs with answers Page - 4

Here, you will find a collection of MCQ questions on Java JSP (Java Server Pages). Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

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()

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ