Which of the following statement(s) is/are TRUE regarding Java Servelets ? (a)…
2017
Which of the following statement(s) is/are TRUE regarding Java Servelets ?
(a) A Java Servelet is a server-side component that runs on the web server and extends the capabilities of a server.
(b) A Servelet can use the user interface classes like AWT or Swing.
Code :
- A.
Only (a) is TRUE.
- B.
Only (b) is TRUE.
- C.
Both (a) and (b) are TRUE.
- D.
Neither (a) nor (b) is TRUE.
Attempted by 261 students.
Show answer & explanation
Correct answer: A
Answer: Only the first statement is true.
Explanation:
The statement that a Java Servlet is a server-side component is true. Servlets run inside a servlet container (for example, Apache Tomcat) and extend the server's capabilities by handling HTTP requests and producing responses. A typical servlet extends HttpServlet and uses lifecycle methods such as init, doGet/doPost, and destroy; the container manages concurrency and request/response objects.
The statement that a servlet can use user interface classes like AWT or Swing is false. AWT and Swing are desktop GUI toolkits that require a graphical display and are intended for client-side applications. Servlets run on the server (often in headless environments) and must generate output (HTML, JSON, etc.) sent to clients. Attempting to create desktop windows on the server is inappropriate and may fail in headless setups; it also does not provide per-client user interfaces.
Recommended practice: implement server-side logic in servlets (or higher-level web frameworks) and deliver UI via HTML/CSS/JavaScript or client-side applications. Do not use desktop GUI libraries on the server.