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
-
ServletRequestAware
-
ServletResponseAware
-
ActionSupport
-
All of them
A
Correct answer
Explanation
To receive the HttpServletRequest instance in a Struts 2 Action class, you implement the ServletRequestAware interface. This interface's setServletRequest(HttpServletRequest) method is called by Struts 2 before the action executes, injecting the request object. ServletResponseAware is for responses, ActionSupport is a convenience base class.
A
Correct answer
Explanation
Action classes in Struts 2 are instantiated on a per-request basis by default. Each request creates a new instance of the action class, which makes actions thread-safe and stateless. This is a key difference from some frameworks where actions might be singletons. The Struts 2 interceptor stack and valueStack work with this per-request instance model.
A
Correct answer
Explanation
JSF includes standard message bundles with predefined error messages for conversion and validation failures. These messages are automatically associated with components and displayed using or tags when errors occur during the Process Validations or Update Model Values phases.
-
Basic Components for Java
-
Basic Controller for Java
-
Business Components for Java
-
Business Controller for Java
C
Correct answer
Explanation
BC4J (Business Components for Java) is Oracle's framework for building J2EE business applications. It provides a layer of abstraction over database operations and follows the MVC pattern. Option C correctly identifies this expansion.
-
request
-
session
-
context
-
page
-
error
-
exception
C
Correct answer
Explanation
JSP implicit objects are: request, response, pageContext, session, application, out, config, page, exception. 'context' is NOT an implicit object - the correct name is 'application' for the ServletContext reference.
-
request
-
session
-
context
-
page
-
error
-
exception
C
Correct answer
Explanation
JSP implicit objects are automatically available in JSP pages without declaration. The standard implicit objects are: request, response, pageContext, session, application (not 'context'), out, config, page, and exception (only in error pages). 'context' is not a valid implicit object name - the correct names are 'application' for servlet context and 'pageContext' for page context.
-
GenericServlet is for servlets that might not use HTTP, like for instance FTP service.
-
As of only Http is implemented completely in GenericServlet.
-
The GenericServlet has a service() method that gets called when a client request is made.
-
GenericServlet is called by both incoming requests and the HTTP requests are given to the servlet as they are.
A,C,D
Correct answer
Explanation
GenericServlet is a protocol-independent servlet class. It defines a lifecycle method service() called for all client requests. Unlike HttpServlet, it does not implement HTTP-specific behavior directly. The marked options correctly describe its protocol-neutral design and request handling workflow.
-
Separation of dynamic and static content.
-
Support for scripting and tags
-
Reuse of components and tags.
-
Web access layer for N-tier enterprise application architecture
A,B,C,D
Correct answer
Explanation
JSP technology provides all four listed advantages: separation of dynamic/static content through its template mechanism, support for scripting and custom tag libraries, component/tag reuse through JavaBeans and custom tags, and serving as the presentation layer in N-tier enterprise architecture.
-
Objects with application scope are accessible from pages processing requests that are in the same application as they one in which they were created.
-
All references to the object shall be released when the runtime environment reclaims the ServletContext.
-
Objects with application scope can be defined (and reached) from pages that are not session-aware
-
References to objects with application scope are stored in the application object associated with a page activation
A,B,C,D
Correct answer
Explanation
All four statements correctly describe application scope in JSP. Objects with application scope are accessible across the entire application (all requests/sessions), persist until the ServletContext is destroyed/reclaimed, can be accessed from non-session-aware pages, and are stored in the implicit application object.
-
cookie.setMaxAge(int seconds)
-
cookie.setMaxAge(float seconds)
-
cookie.setAgeMax (float seconds)
-
cookie.setAgeMax (int seconds)
A
Correct answer
Explanation
The Cookie class in Java servlets/JSP uses setMaxAge(int seconds) to set the cookie's maximum age in seconds. The parameter must be an integer, not a float. Negative values delete the cookie, zero deletes it immediately, and positive values set the expiration time.
-
_jspService()
-
jspInit()
-
jspDestroy()
-
getParameter()
B,C
Correct answer
Explanation
In JSP, only jspInit() and jspDestroy() can be overridden by developers. The _jspService() method is generated by the container and cannot be overridden (it's marked final in the generated servlet). getParameter() is a method of ServletRequest interface, not a JSP lifecycle method.
-
HTTP Communication (Text-based and object-based)
-
Socket Communication
-
RMI Communication
-
None of these
A,B,C
Correct answer
Explanation
Applets can communicate with servlets using HTTP requests (sending text or serialized objects), direct TCP/IP sockets, or Remote Method Invocation (RMI). Since all three communication mechanisms are valid, marking them all as correct in this multiple-response question is accurate.
A
Correct answer
Explanation
While JSP pages primarily use the JspWriter implicit object 'out', developers can explicitly access ServletOutputStream through response.getOutputStream() when binary output is needed. This is valid JSP/servlet API behavior, making the statement true.
A
Correct answer
Explanation
JSP and Servlets can invoke external applications using Runtime.getRuntime().exec() or ProcessBuilder. The external process runs on the server side, not the client browser. This is useful for server-side processing but requires proper security considerations.