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
-
Parsing JSP using an XML Parser.
-
Converting JSP into static Html content.
-
Generating Servlet Code for the Jsp
-
None
C
Correct answer
Explanation
JSP translation refers to the process where the JSP container converts the JSP file into a corresponding Servlet source code. This generated servlet is then compiled. The servlet handles requests by generating HTML output. Option A is wrong because JSP uses its own parser, not generic XML. Option B is wrong because JSP becomes dynamic servlet code, not static HTML.
-
Applets
-
Web Browsers
-
Wireless clients.
-
All the above
D
Correct answer
Explanation
J2EE supports multiple client types for accessing enterprise applications. Applets are client-side Java programs that run in browsers. Web browsers are the most common J2EE clients using HTTP. Wireless clients include mobile devices and PDAs that access J2EE applications through WAP or similar protocols. Since all three are valid J2EE client types, option D is correct.
B
Correct answer
Explanation
The statement is false because while HTTP-based servlets extend HttpServlet, the Servlet API also supports generic servlets that extend javax.servlet.GenericServlet. GenericServlet is protocol-independent and can be used for any protocol, not just HTTP. HttpServlet specifically handles HTTP requests and responses.
B
Correct answer
Explanation
The JSP translation to servlet happens only once when the JSP is first requested or when it has been modified. The web container compiles the JSP into a servlet class and caches it. Subsequent requests execute the already-compiled servlet without retranslation. This makes JSP processing efficient after the initial compilation.
-
Yes, but always call the default constructor.
-
Yes, but you do not have to always call the default constructor.
-
No
-
None
-
ServletContext gives information about Container
-
ServletContext gives information about Request
-
ServletContext gives information about Session
-
None
A
Correct answer
Explanation
The ServletContext interface defines a set of methods that a servlet uses to communicate with its servlet container, offering details about the server environment. It does not contain information specific to individual client requests or sessions.
-
only request, response
-
only request, response & application
-
request, response, session & application
-
none of the above
C
Correct answer
Explanation
JSP provides several implicit objects that are automatically available: request (HttpServletRequest), response (HttpServletResponse), session (HttpSession), application (ServletContext), out (JspWriter), pageContext, page, config, and exception. Option C correctly identifies the core implicit objects for request handling and session/application management.
A
Correct answer
Explanation
When a JSP is requested, the web container translates it into a servlet class and compiles it. The servlet is then instantiated, creating a servlet instance (object). This instance is initialized and then used to service requests. The servlet instance exists in memory to handle requests to that JSP.
-
ejb-jar.xml
-
Can be any valid xml containing Web Module name
-
web.xml
-
config.xml
C
Correct answer
Explanation
The web.xml file is the standard deployment descriptor for Java web applications. It contains configuration information such as servlet mappings, filter definitions, welcome file lists, context parameters, security constraints, and other application settings. The web container reads web.xml during application deployment to configure the application.
A
Correct answer
Explanation
Servlets are designed to handle multiple concurrent requests efficiently. The servlet container typically maintains a single servlet instance per servlet and creates a separate thread for each request. This allows the same servlet instance to service multiple requests simultaneously. Developers must ensure thread-safe code when handling shared resources.
A
Correct answer
Explanation
ServletContext provides servlets with access to configuration parameters, server information, and resources shared across the application. It serves as the interface between servlets and their runtime environment, enabling communication with the web container.
-
init()
-
service()
-
destroy()
-
All the above
D
Correct answer
Explanation
Servlets have three core life-cycle methods: init() for initialization, service() for request processing, and destroy() for cleanup. All are invoked by the container at different stages of the servlet's existence.
B
Correct answer
Explanation
Each web application has exactly one ServletContext object shared by all servlets within that application. It provides application-wide scope for attributes and initialization parameters, unlike ServletConfig which is per-servlet.
A
Correct answer
Explanation
Servlet containers typically use a thread pool where each request is handled by a separate thread. This makes servlets inherently multi-threaded, requiring careful attention to thread safety when handling shared resources.
-
getServletInfo()
-
getInitParameters()
-
getServletConfig()
-
None
C
Correct answer
Explanation
The getServletConfig() method returns the ServletConfig object passed to the init() method. This object provides access to servlet-specific initialization parameters. getServletInfo() returns servlet information, and getInitParameters() is not a standard method.