Computer Knowledge
Java Enterprise and Web Technologies
2,279 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
-
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.
-
HTML
-
JavaScript
-
JSP
-
Sevlets
C,D
Correct answer
Explanation
JSP and Servlets are server-side Java technologies that run on the web server and generate dynamic content. HTML is purely client-side markup, and JavaScript (in this traditional context) is primarily a client-side scripting language.
-
Java Server Pages
-
Java Server Programming
-
Java Service Pages
-
Java Service Programming
A
Correct answer
Explanation
JSP stands for Java Server Pages, a server-side technology that enables the creation of dynamic web content with Java code embedded in HTML templates. It simplifies the development of web applications with a presentation-focused approach.
-
Apache Tomact
-
Bea WebLogic
-
Servlets
-
JSP Engine
A,B,D
Correct answer
Explanation
JSP requires a servlet container with JSP support - Apache Tomcat and BEA WebLogic are such servers. JSP Engine is the component within these servers that processes JSP pages. Servlets themselves are not a runtime environment but rather Java classes.
-
jar
-
war
-
jar, war
-
jar, war, ear
C
Correct answer
Explanation
JAR (Java Archive) files contain Java libraries and classes. WAR (Web Application Archive) files are specifically designed for web applications and contain web components like servlets, JSPs, HTML, etc. EAR (Enterprise Archive) files are for J2EE enterprise applications deployed to application servers. Both JAR and WAR files can be deployed in appropriate web servers or servlet containers, making option C correct.