Computer Knowledge
Java Enterprise and Web Technologies
2,183 Questions
Java enterprise and web technologies questions focus on J2EE architecture, web services like SOAP, and servlet functionalities. These topics frequently appear in IT officer and specialist scale examinations. Regular practice ensures familiarity with enterprise application components.
HttpServlet methodsSOAP and web servicesEJB architecture rolesJ2EE componentsJSP servlet callingUDDI concepts
Java Enterprise and Web Technologies Questions
-
setContentWriter()
-
setWriter()
-
setPrintType()
-
setContentType()
D
Correct answer
Explanation
The setContentType() method must be called before using PrintWriter because it sets the content type (MIME type) of the response being sent to the client. Once the PrintWriter is obtained and used to write content, the response headers are committed and cannot be modified.
-
jspDestroy()
-
jspInit()
-
_jspService()
-
getParameter()
C
Correct answer
Explanation
The _jspService() method is generated automatically by the JSP container and contains the servlet's code. It cannot be overridden in a JSP page, whereas jspInit() and jspDestroy() can be defined by the developer.
-
jspDestroy()
-
jspInit()==
-
_jspService()
-
getParameter()
A
Correct answer
Explanation
The jspDestroy() method can be overridden in a JSP page to perform cleanup operations when the page is being unloaded or the JSP container is shutting down. This is part of the JSP lifecycle, parallel to the destroy() method in Servlets.
-
readOnly==
-
dynamic
-
static==
-
None of the above
C
Correct answer
Explanation
The <%@ include file="..." %> directive includes a static file at translation time. The content is inserted into the JSP page when it is compiled into a Servlet, making it a static include rather than a runtime (dynamic) include.
-
AirthmaticFormat
-
CurrencyFormat
-
NumberFormat ==
-
StringBuffer
C
Correct answer
Explanation
To solve this question, the user needs to know what class can be used for formatting money on a JSP page.
The correct answer is:
C. NumberFormat
Option C is correct because the NumberFormat class is used for formatting numbers, including currency values. It provides methods for formatting numbers into strings that can be displayed on a JSP page. The CurrencyFormat class does not exist in Java and AirthmaticFormat and StringBuffer are not used for formatting currency values.
Therefore, the answer is: C. NumberFormat.
-
<%= expressions %>
-
<% code fragment %
-
<%! Declarations %>
-
<%-- comment -- %>
B
Correct answer
Explanation
The <% code fragment %> tag (scriptlet) contains Java code fragments that are valid in the page scripting language. This code is placed in the _jspService() method of the generated Servlet and executes during request processing.
-
None of the above
-
content safe
-
synchornised
-
thread safe
D
Correct answer
Explanation
Setting <%@ page isThreadSafe="false" %> indicates the JSP is not thread-safe, implementing the SingleThreadModel interface. This ensures only one thread executes the JSP at a time by serializing requests through the same servlet instance, making it thread-safe by preventing concurrent access.
-
Web Rendering Engine
-
Application Framework
-
Client Engine
-
Server Engine
A
Correct answer
Explanation
The Web Application Container in Echo2 framework is an extension of the Web Rendering Engine. This engine handles the rendering and lifecycle of web components in the Echo2 architecture.
-
service() method is invoked by the container once per request.
-
service() method can be invoked only once.
-
init() is invoked by the container only once per request.
-
init() is invoked by the container only once per instance.
A,D
Correct answer
Explanation
In the servlet lifecycle, the service() method is invoked by the container for each incoming request, making it responsible for request processing. The init() method is called only once per servlet instance when it's first loaded, not for each request. This lifecycle design ensures efficient resource management - initialization happens once, while request handling can occur many times concurrently.
-
Generic Servlet is an Abstract Class and it extends Servlet Config Class
-
HttpServlet is an Abstract class extending Generic Servlet Abstract Class.
-
HttpServlet is an Abstract Class that extends Servlet Interface.
-
Generic Servlet is an Abstract Class and it extends Servlet Config Interface
A,C,D
Correct answer
Explanation
JSP implicit objects are automatically available in JSP pages. 'exception' is available only in error pages. 'out' is the JspWriter object. 'page' refers to the current servlet instance (this). 'error' is not a valid JSP implicit object.
C
Correct answer
Explanation
SAAJ (SOAP with Attachments API for Java) is specifically designed for sending XML documents and attachments over the Internet using SOAP protocol. JAXB is for XML binding to Java objects, JAXR for registry access, and JAX-RPC for remote procedure calls via SOAP.
B
Correct answer
Explanation
SOA (Service-Oriented Architecture) is an architectural design pattern that can be implemented using various technologies including web services, CORBA, REST APIs, message queues, or other distributed computing approaches. Web services are one popular implementation but not the only way.
-
Simple Access API for Java
-
SOAP with Attachments API for Java
-
Serial Access API for Java
-
Sun Access API for Java
B
Correct answer
Explanation
SAAJ stands for SOAP with Attachments API for Java. It's a Java API for creating and sending SOAP messages with attachments. The other options are fabricated: Simple Access, Serial Access, and Sun Access are not real Java API names.
A
Correct answer
Explanation
AJP (Apache JServ Protocol) is the wire protocol enabling communication between Apache web server and Tomcat. HTTP is for web communication, FTP for file transfer, and AJAX for asynchronous web updates.