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
-
URL rewriting may be used by a server as the basis for session tracking.
-
SSL has a built-in mechanism that a servlet container could use to obtain data used to define a session.
-
When using cookies for session tracking, the name of the session tacking cookie must be JSESSIONID.
-
IF a user has cookies disabled in the browser, the container may choose to use a javax.servlet.httpCookielessHttpSession object to track the user's session.
D
Correct answer
Explanation
Option D is FALSE (making it the correct answer to 'which is NOT true') because there is no such class as javax.servlet.http.CookielessHttpSession in the Servlet API. When cookies are disabled, containers use URL rewriting (appending the session ID to URLs) - they don't switch to a different HttpSession implementation class. Options A, B, and C are all TRUE statements: URL rewriting is a valid session tracking mechanism; SSL sessions can be used; and JSESSIONID is the standard cookie name (though containers can configure a different name).
A
Correct answer
Explanation
Session attributes are shared across all servlets within the same ServletContext (web application). When you store an attribute in an HttpSession using setAttribute(), any other servlet in the same application can retrieve it using getAttribute() on the same session (identified by the same session ID). This sharing is a key purpose of session attributes - to maintain user-specific state across multiple servlets/JSPs in the application. Different ServletContexts have separate session scopes.
-
req.getSession(false);
-
req.getSession(true);
-
both the above
-
none of the above
B
Correct answer
Explanation
HttpServletRequest.getSession(true) returns the current session or creates a new one if none exists. The boolean parameter 'create' controls this behavior: true means create if needed, false means return null if no session exists. Option A (getSession(false)) would return null instead of creating a session. The method getSession() with no arguments is equivalent to getSession(true) - it also creates sessions.
-
They should be used for data that changes rarely.
-
They can be accessed using ServletContext.getInitParameter()
-
They can be accessed using ServletContext.getParameter()
-
They should be used for data that is applicable to an entire web application.
C
Correct answer
Explanation
Option C is FALSE (making it the correct answer to 'which is NOT true') because ServletContext has no getParameter() method - the correct method is getInitParameter(). Options A, B, and D are all TRUE: ServletContext init parameters are configured in web.xml, meant for data that rarely changes (like database connection strings), are application-wide (shared by all servlets), and are accessed using getInitParameter(String name).getParameter() methods exist on HttpServletRequest, not ServletContext.
-
getMethod()
-
getHeader()
-
getCookies()
-
getInputStream()
D
Correct answer
Explanation
ServletRequest.getInputStream() is declared in the ServletRequest interface and returns a ServletInputStream for reading the request body as binary data. Options A, B, and C are wrong because getMethod(), getHeader(), and getCookies() are declared in HttpServletRequest (which extends ServletRequest), not in ServletRequest itself. ServletRequest contains fundamental methods like getParameter(), getAttribute(), getInputStream(), and getReader(), while HttpServletRequest adds HTTP-specific methods.
-
getServletInfo()
-
getInitParameters()
-
getServletConfig()
-
None
C
Correct answer
Explanation
In the init(ServletConfig) method, the ServletConfig object is passed as a parameter and can be accessed directly. The getServletConfig() method returns this stored config object, which is useful in other methods throughout the servlet lifecycle. getServletInfo() returns servlet information (not config), and getInitParameters() is not a standard method.
-
singleton
-
Prototype
-
request
-
response
D
Correct answer
Explanation
Spring defines five bean scopes: singleton (default), prototype, request, session, and global session. 'response' is NOT a valid scope in Spring - the option list includes singleton, prototype, and request, which ARE all valid Spring scopes, making 'response' the correct answer for what is NOT defined.
-
Application scope
-
Application Integration
-
Application Context
-
None
C
Correct answer
Explanation
The ApplicationContext is Spring's bootstrap mechanism that loads all high-level entry-point objects required by your application. It provides configuration for the application, reads bean definitions, and assembles them at runtime. Application scope is a bean scope, and Application Integration is not a standard Spring term.
-
Constructor Injection
-
Setter Injection
-
interface Injection
-
None
C
Correct answer
Explanation
Spring supports constructor injection (via dependencies in constructor), setter injection (via setter methods), and field injection (via annotations). Interface injection is NOT supported by Spring - it was part of early DI frameworks but Spring chose not to implement it, preferring the other three approaches.
-
Desktop & web Application
-
Desktop
-
Web Application
-
Other
A
Correct answer
Explanation
Java is widely used for both desktop applications (Swing, JavaFX) and web applications (servlets, JSP, Spring). The most complete answer includes both domains.
-
Data Access Object.
-
MVC
-
Business Delegate
-
Service Locator.
-
Web Services
-
Struts
-
JDBC
-
EJB
B
Correct answer
Explanation
Struts is a MVC framework specifically designed for building presentation layers in J2EE applications. It provides structured web application development with clear separation between Model, View, and Controller components. Web Services are for service-oriented architecture, JDBC is for database connectivity, and EJB is for business logic and enterprise services.
-
Hibernate
-
Spring Framework
-
ILOG Jrules.
-
Savvion.
C
Correct answer
Explanation
ILOG JRules (now IBM Operational Decision Manager) is a Business Rule Management System (BRMS) that enables both business users and developers to collaboratively manage business rules. It provides tools for rule authoring, testing, and deployment in a centralized repository. Hibernate is an ORM framework, Spring is a comprehensive framework, and Savvion is a Business Process Management Suite.
-
Top Down Approach
-
Bottom Up Approach
-
Top Left Approach
-
Bottom Right Approach
B
Correct answer
Explanation
The Bottom Up Approach in web services development starts with writing the Java class first, then generating the WSDL (Web Services Description Language) from it. This contrasts with the Top Down Approach where you start with a WSDL contract and generate the Java class from it.
-
Find
-
Bind
-
Publish
-
EndPoint.
C
Correct answer
Explanation
In the SOA publish-find-bind model, the Publish interaction occurs between the Service Provider and the Registry. The provider publishes information about its service to the registry so consumers can later find it. Find is between Consumer and Registry, Bind is between Consumer and Provider.