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

Multiple choice technology programming languages
  1. out

  2. session

  3. request

  4. response

  5. httpsession

  6. page

Reveal answer Fill a bubble to check yourself
E Correct answer
Explanation

JSP provides implicit objects like out, request, response, session, and page that can be used directly in expressions. 'httpsession' is not a valid JSP implicit variable - the session object itself is an HttpSession, not a variable called 'httpsession'. Options A, B, C, D, and F are all standard implicit objects available in JSP expressions.

Multiple choice technology programming languages
  1. G. <jsp:usebean id="fruit scope ="page"/>

  2. H. <jsp:usebean id="fruit type ="String"/>

  3. I. <jsp:usebean id="fruit type ="String" beanName="Fruit"/>

  4. J. <jsp:usebean id="fruit class="Fruit" beanName="Fruit"/>

Reveal answer Fill a bubble to check yourself
B,C Correct answer
Explanation

The action requires either a class or type attribute. Option B correctly uses only the type attribute with proper syntax. Option C is also valid as it combines type with beanName (used with type but not class). Option A has malformed scope attribute (missing equals), and option D incorrectly combines class with beanName which are mutually exclusive alternatives.

Multiple choice technology programming languages
  1. A. The getRequestDispatcher method of ServletContext class takes the full path of the servlet, whereas the getRequestDispatcher method of HttpServletRequest class takes the path of the servlet relative to the ServletContext.

  2. B. The include method defined in the RequestDispatcher class can be used to access one servlet from another. But it can be invoked only if no output has been sent to the server.

  3. C. The getRequestDispatcher(String URL) is defined in both ServletContext and HttpServletRequest method

  4. D. The getNamedDispatcher(String) defined in HttpServletRequest class takes the name of the servlet and returns an object of RequestDispatcher class.

Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

Option A correctly states that ServletContext.getRequestDispatcher uses full paths (starting with '/'), while HttpServletRequest.getRequestDispatcher uses paths relative to the current context. Option C is also correct - both interfaces define getRequestDispatcher with different path resolution rules. Option B is incorrect because include can be invoked after output. Option D is wrong because getNamedDispatcher is in ServletContext, not HttpServletRequest.

Multiple choice technology programming languages
  1. /META-INF/classes

  2. /classes

  3. /WEB-INF/classes

  4. /root/classes

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In a WAR file, compiled Java classes must be placed in the WEB-INF/classes directory, maintaining their package structure. Options A, B, and D do not follow the WAR specification. The WEB-INF directory contains private resources that cannot be directly accessed by clients, making it the correct location for class files.

Multiple choice technology web technology
  1. <f:faces>

  2. <f:view>

  3. <h:jsf>

  4. <h:view>

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To solve this question, the user needs to have knowledge of JavaServer Faces (JSF) and its structure.

The correct answer is:

B.

The tag must enclose all other tags on a Faces JSP page. It represents the outermost container for a JavaServer Faces (JSF) application and is used to define the view that is to be rendered.

Option A, , is not a valid JSF tag.

Option C, , is not a valid JSF tag either.

Option D, , is a valid JSF tag, but it is not the correct answer to this question. The correct tag is .

Multiple choice technology web technology
  1. To keep track of its identifier

  2. To keep track of the components in tree

  3. To set its submitted property

  4. For JavaScript integration

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The HtmlForm component in JSF renders a hidden field to track its submitted state during the request processing lifecycle. This hidden field helps JSF determine whether the form has been submitted and distinguishes between initial form display and postback requests. The hidden field is not for tracking identifiers (A), component trees (B), or JavaScript integration (D) - those are handled by other JSF mechanisms.

Multiple choice technology web technology
  1. #{contextPath}

  2. #{requestContextPath}

  3. #{facesContext.externalContext.requestContextPath}

  4. ${request.contextPath}
Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In JSF, the full expression #{facesContext.externalContext.requestContextPath} accesses the external context to retrieve the request’s context path, which is the correct way to reference the application’s base URL. The other shorter forms either reference non‑existent properties or use the wrong EL syntax, making them incorrect.

Multiple choice technology databases
  1. doGet()

  2. doTrace()

  3. doOptions()

  4. All the Above

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

HttpServlet class provides doGet(), doTrace(), doOptions(), doPost(), doPut(), doDelete(), and other methods corresponding to HTTP protocol verbs. Since doGet, doTrace, and doOptions are all valid HttpServlet methods, 'All the Above' is the correct answer.

Multiple choice technology databases
  1. Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage.

  2. JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.

  3. JSP and servlets are unrelated technologies.

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

JSP (JavaServer Pages) is built on servlet technology. During deployment, JSP pages are compiled into servlets by the container. Servlets are the underlying technology, not the other way around. JSP provides a template-based approach for generating dynamic content, but ultimately executes as servlets.

Multiple choice technology databases
  1. GenericServlet

  2. HttpServlet

  3. Both (A) and (B)

  4. None of the Above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In Java Servlet API, both GenericServlet (a protocol-independent servlet) and HttpServlet (a servlet specifically tailored for HTTP requests) are types of servlets. Therefore, both are valid servlet implementations, making the option "Both (A) and (B)" correct.

Multiple choice technology databases
  1. JSP Page

  2. Java bean

  3. Servlet

  4. Session manager

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In Page-Centric architecture, the JSP page itself is the initial contact point for handling web requests. Unlike servlet-centric architectures where a servlet receives and processes requests first, page-centric designs route requests directly to JSP pages which may then delegate to beans or other components as needed.

Multiple choice technology databases
  1. doGet() or doPost() method

  2. getServletInfo() method

  3. All of the above

  4. none of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To process form submissions in a servlet, you subclass HttpServlet and override the doGet() or doPost() methods, depending on the HTTP request method used. The service() method automatically dispatches requests to these methods, so developers rarely need to override service() directly.

Multiple choice technology databases
  1. service() method

  2. init() method

  3. constructor for HttpServlet()

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The init() method is the designated place for servlet initialization code in the Servlet API lifecycle. It's called once when the servlet is first loaded. The service() method handles each request. The constructor is not the standard initialization point for servlets - init() guarantees the ServletConfig is available.

Multiple choice technology databases
  1. ServletContext

  2. Servlet mapping

  3. Lifecycle

  4. None of the Above

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Servlet mapping is the association between a URL pattern and a servlet, defined in web.xml (or annotations). It tells the container which servlet should handle requests matching specific URL patterns. ServletContext is shared data across servlets. Lifecycle refers to servlet initialization/destruction. The mapping mechanism is essential for routing requests to correct servlets.

Multiple choice technology databases
  1. Servlet Interface

  2. servlet mapping

  3. Servlet Container

  4. None of the Above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

All Servlets must implement the javax.servlet.Servlet interface, which defines the lifecycle methods (init, service, destroy) that the servlet container calls. Servlet mapping is a configuration concept, and Servlet Container is the runtime environment, not an interface to implement.