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. <error-page> <error-code>404</error-code> <location>/error.jsp</location> </error-page>

  2. <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> <location>/error.jsp</location> </error-page>

  3. <error-page> <exception-type>mypackage.MyException</exception-type> <error-code>404</error-code> </error-page>

  4. <error-page> <exception-type>mypackage.MyException</exception-type> <location>/error.jsp</location> </error-page>

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

Error-page configuration supports two formats: using error-code for HTTP status codes (option A) OR using exception-type for Java exceptions (option D). Both require a location element pointing to the error page. Options B and C incorrectly mix both error-code and exception-type in the same error-page element - only one should be specified per error-page entry.

Multiple choice technology programming languages
  1. <listener>MyClass</listener>

  2. <listener> <listener-class>MyClass</listener-class></listener>

  3. <listener> <listener-name>aListener</listener-name> <listener-class>MyClass</listener-class> </listener>

  4. <listener> <servlet-name>myServlet</servlet-name> <listener-class>MyClass</listener-class> </listener>

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

The listener element in web.xml must contain a listener-class subelement specifying the fully-qualified class name of the listener class. Option A is missing the listener-class wrapper. Option C incorrectly includes listener-name (which is not a valid element). Option D incorrectly references servlet-name (listeners are not tied to specific servlets). Only option B shows the correct structure.

Multiple choice technology programming languages
  1. web

  2. web-app

  3. name

  4. display-name

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

The root element of the Java web application deployment descriptor (web.xml) is web-app. This element contains all other configuration elements like servlet, servlet-mapping, filter, context-param, etc. Options A (web), C (name), and D (display-name) are not the root element name, though display-name can be a subelement within web-app.

Multiple choice technology programming languages
  1. param-name

  2. name

  3. init-param

  4. servlet-name

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

The context-param element in web.xml requires two subelements: param-name (the parameter name) and param-value (the parameter value). Option A correctly identifies param-name as required. Options B (name), C (init-param), and D (servlet-name) are incorrect - name is not a valid element, init-param is for servlet configuration, and servlet-name is used elsewhere in the descriptor.

Multiple choice technology programming languages
  1. The code does not compile as there is no property attribute of setProperty tag.

  2. The code does not compile as property attribute cannot take * as a value.

  3. The code sets value of all properties of employee bean to "*".

  4. The code sets the values of all properties of employee bean to matrching parameters in request object.

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

The jsp:setProperty tag with property="*" is a special shorthand that automatically sets all bean properties to matching request parameters. For each property in the bean, it looks for a request parameter with the same name and sets the value using appropriate type conversion. Option A is wrong - setProperty does have a property attribute. Option B is wrong - * is a valid special value. Option C is wrong - * is a wildcard, not a literal string value.

Multiple choice technology programming languages
  1. The JSTL code does not compile as an attribute for forEach tag is not correct.

  2. 0

  3. 2

  4. ABC

  5. Nothing gets printed as c.out statement does not get executed.

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

The forEach loop with begin=0, end=0, step=2 executes once with index=0. The var='item' sets the loop variable to 0. outputs 0. The key is that begin=0 end=0 means 'iterate from index 0 to index 0' in JSTL.

Multiple choice technology programming languages
  1. No number gets printed.

  2. One number gets printed.

  3. Two numbers gets printed.

  4. Three numbers gets printed.

  5. Four numbers gets printed.

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

To solve this question, the user needs to know the working of the JSTL choose tag and the conditions used in the when tags.

The code fragment defines a variable 'item' whose value is set to 2. The code then goes on to use the choose tag which is used for conditional processing. The choose tag contains multiple when tags. The when tags are evaluated in the order they are written, and the first condition that is true gets executed. If none of the conditions is true, the code in the otherwise tag is executed.

Looking at the code, the value of the 'item' variable is 2. The first condition in the when tags is "${item>0}" which is true for the given value of item. Therefore, the code inside the first when tag is executed which prints the number 1. The code doesn't go on to evaluate the other when tags because the first condition is true.

So, the answer is:

The Answer is: B. One number gets printed.

Multiple choice technology programming languages
  1. 1

  2. 2

  3. 3

  4. 4

  5. abc

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

The c:forEach tag processes the comma-separated string as a collection. The 'begin' and 'end' attributes are zero-indexed relative to the items. Index 1 refers to the second item ('3') and index 2 refers to the third item ('2'). Therefore, 3 and 2 are printed.

Multiple choice technology programming languages
Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The correct URI for JSTL 1.1 core library is http://java.sun.com/jsp/jstl/core. This follows the standard pattern for JSTL 1.x taglib URIs. The other options are incorrect: they omit 'jstl' or use incorrect versioning.

Multiple choice technology web technology
  1. a. Two Administration server and one Managed servers

  2. b. One Administration server and optional Managed servers

  3. c. One Administration server and two Managed servers

  4. d. None of the above

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

A WebLogic Domain must have exactly one Administration Server, which serves as the central management point. The number of Managed Servers is optional - you can have zero, one, or many Managed Servers depending on your scalability needs. Options A and C incorrectly specify fixed numbers of Managed Servers.

Multiple choice technology web technology
  1. a. HTTP server

  2. b. Web server

  3. c. Application server

  4. d. None of the above

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

Oracle WebLogic Server is a Java EE application server. While it includes web server capabilities (handling HTTP), its primary role is providing a platform for developing and deploying multi-tier distributed enterprise applications, including business logic and database connectivity, which distinguishes it from a simple web server.

Multiple choice technology web technology
  1. a. Only WAR files

  2. b. Only EAR files

  3. c. Only SAR files

  4. d. All of the above.

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

WebLogic Server can deploy multiple archive formats: WAR files for web applications, EAR files for enterprise applications (which can contain multiple modules), and SAR files for service archives. 'All of the above' is correct because WebLogic supports all these deployment formats, not just one type.