M.C.A Computer Aplications Enterprise Java (MC335) : October 2008 Question paper

Started by ganeshbala, Mar 12, 2009, 11:55 PM

Previous topic - Next topic

ganeshbala

M.C.A Computer Aplications Enterprise Java (MC335) : October 2008 Question paper

Question Paper
Enterprise Java
(MC335) : October 2008

Section A : Basic Concepts (30 Marks)
· This section consists of questions with serial number 1 - 30.
· Answer all questions.
· Each question carries one mark.
· Maximum time for answering Section A is 30 Minutes.

1. In which file do we define a servlet mapping?(a) web.xml
(b) servlet.mappings
(c) servlet.xml
(d) Simple.java
(e) Xml.web.

2. All servlets must implement the Servlet interface of which package?(a) java.servlet
(b) javax.servlet
(c) .servlet
(d) Servlet.javx
(e) Servlet.javaexe.

3. The Web server that executes the servlet creates a/an _______ object and passes this to the servlet's service method (which, in turn, passes it to doGet or doPost).(a) HttpServletResponse
(b) HttpRequest
(c) ServletRequest
(d) HttpServletRequest
(e) HttpRequestServlet.

4. The client can access the servlet only if the servlet is installed on a ________ that can respond to servlet requests.(a) Client
(b) Server
(c) Internet
(d) In your network
(e) All (a), (b), (c) and (d) above.

5. Java Networking Java 1.1 natively supports which of the following protocols?I. TCP.II. UDP.III. SMB.(a) Both (I) and (II) above
(b) Only (I) above
(c) Both (II) and (III) above
(d) Both (I) and (III) above
(e) All (I), (II) and (III) above.

6. Which is true regarding cookies?(a) Cookies can survive server crashes because they are stored on the client's hard disk
(b) They increase the load on the server's memory
(c) Cookies cannot be read by unauthorized users
(d) Cookies can lighten the load on the network
(e) Users cannot disable cookies in their web browsers.

7. A Cookie is(a) A small file that a Web browser sends to the Web Server
(b) A small file that a Web browser sends to the Application Server
(c) A small file that a Web Server sends to the Application Server
(d) A small file that a Web Server sends to the Web browser
(e) A small variable either at Server or Client.

8. Which of the following can be used to store client side user state information while avoiding any impact due to the users web browser configuration?(a) Cookies
(b) URL rewriting
(c) HttpSessions
(d) Hidden tags
(e) Httpcookies.

9. Parameters are passed as _______ pairs in a get request.I. Value. II. Name/value. III. Session.(a) Only (I) above
(b) Only (II) above
(c) Both (I) and (II) above
(d) Both (II) and (III) above
(e) Both (I) and (III) above.

10. Which of the following identifies the correct method a servlet developer should use to retrieve form data from the client provided to the doPost() method ?(a) getParameter() against the HttpServletRequest object
(b) getInputStream() against the HttpServletrequest object
(c) getBytes() against the HttpServletrequest object
(d) getQueryString() against the HttpServletrequest object
(e) getStringQuery() against the HttpServletrequest object.

11. Choose the statement that best describes the relationship between JSP and servlets.(a) Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage
(b) JSP and servlets are unrelated technologies
(c) Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The two technologies are not useful in combination
(d) JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage
(e) All of the above.

12. What is a benefit of using JavaBeans to separate business logic from presentation markup within the JSP environment?I. It allows the JSP to access middleware. II. It provides a dynamic markup environment, such that JavaBeans are integrated seamlessly with the template presentation content, in order to create the dynamic display for the client. III. It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
(e) Both (II) and (III) above.

13. What alternative exists to embedding Java code directly within the HTML markup of your JSP page?(a) Moving the code into your session manager
(b) Moving the code into scriptlets
(c) Moving the code into JavaBeans and servlets
(d) Moving the code into a transaction manager
(e) Moving the code into a Asp code.

14. What type of scriptlet code is better-suited to being factored forward into a servlet?(a) Code that deals with logic that is common across requests
(b) Code that deals with logic that is vendor specific
(c) Code that deals with logic that relates to database access
(d) Code that deals with logic that relates to client scope
(e) Code that deals with logic that relates to itself.

15. Choose the statement that best describes how to connect JSP pages and Enterprise JavaBeans (EJBs).(a) Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean
(b) Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics
(c) Lookup the EJBs from within a servlet, delegating usage to specific JSP pages
(d) Lookup and use the EJBs from within a JSP page, but only as remote references
(e) Lookup the servlets within EJBs delegating usage to specific HTML pages.

16. What is the initial contact point for handling a web request in a Page-Centric architecture?(a) A JSP page
(b) A JavaBean
(c) A servlet
(d) A session manager
(e) An Entity.

17. What is the difference between doing an include or a forward with a RequestDispatcher?(a) The two methods provide the same functionality, but with different levels of persistence
(b) The forward method is deprecated as of JSP 1.1 and the include method should be used in order to substitute portions of a dynamic display at runtime
(c) The include method transfers control to a dynamic resource, while the forward method allows for dynamic substitution of another JPS pages output, returning control to the calling resource
(d) The forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page
(e) All of the above.

18. The action can pass parameters to the page which it is including. How does this second page obtain the value of these parameters?(a) Using the action
(b) Using the action
(c) Use the request.getParameter() method
(d) Use the response.getParam() method
(e) Use the request.Paramterter() method.

19. When a JSP page is compiled, what is it turned into?(a) Applet
(b) Servlet
(c) Application
(d) Mailet
(e) Asp.

20. Which of the following is legal JSP syntax to print the value of i. Select the one correct answer?(a) <%int i = 1;%><%= i; %>
(b) <%int i = 1;i; %>
(c) <%int i = 1%><%= i %>
(d) <%int i = 1;%><%= i %>
(e) <%int i = 1%><%= i; %>.

21. What does JSP stand for?(a) Java Server Pages
(b) Java Special Pages
(c) Java Static Pages
(d) Java Showing Pages
(e) Java Status pages.

22. Through what interface does an application create, find, and remove enterprise beans?(a) java.rmi.Remote
(b) javax.ejb.EJBHome
(c) javax.ejb.EJBObject
(d) javax.ejb.EntityBean
(e) java.ejb.HomeEJB.

23. What type of enterprise bean is used to embody business objects?(a) javax.ejb.EnterpriseBean
(b) java.rmi.Remote
(c) javax.ejb.SessionBean
(d) javax.ejb.EntityBean
(e) java.ejb.Entity.

24. What type of enterprise bean is used to embody application processing state information?(a) javax.ejb.EnterpriseBean
(b) javax.rmi.Remote
(c) javax.ejb.SessionBean
(d) javax.ejb.EntityBean
(e) Javax.EntityBean.

25. What interface must the enterprise bean implement so that an application can invoke its operations?(a) javax.ejb.EntityBean
(b) javax.ejb.EJBHome
(c) javax.rmi.Remote
(d) javax.ejb.EJBObject
(e) javax.EntityBean.EJB.

26. What is a deployment descriptor?(a) An XML file format used by the container to learn about the attributes of a bean, such as transactional characteristics and access control
(b) A method for transporting enterprise beans back and forth between systems
(c) An XML file used by enterprise bean clients to learn about the attributes of a bean, such as access control and transactional characteristics
(d) A format for bundling enterprise beans for delivery to customers
(e) An object of JSP.

27. A stateless session beanI. Is created when the client invokes create on the home.II. There must be one per client as long as the client is executing the business logic. III. Is the most scalable type of bean.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
(e) Both (II) and (III) above.

28. When a bean moves from the "does not exist" to the "method ready" status, in which order do the events take place?I. construction,ejbCreate(),setSessionContext().II. construction,setSessionContext(),ejbCreate() .III. setSessionContext() only take place.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
(e) Both (II) and (III) above.

29. For remote objects Java passes objectsI. By reference. II. By object copy. III. By producing a serialized copy.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (III) above
(e) Both (II) and (III) above.

30. If you want to override a JSP file's initialization method, within what type of tags must you declare the method?(a) <@ @>
(b) <%@ %>
(c) <% %>
(d) <%! %>
(e) <@! %>.


END OF SECTION A

Section B : Problems (50 Marks)
· This section consists of questions with serial number 1 –5.· Answer all questions. · Marks are indicated against each question.· Detailed workings should form part of your answer. · Do not spend more than 110 - 120 minutes on Section B.
1. In companyAppLABS the salary structure is based upon the category and the basic pay. The 'emp' table has the following fields:Empid, Fname, Lname, Category, BasicPay.The salary consists of the components as follows:Salary Component Category 1 Category 2 Category 2 Category 2
DA 87% 65% 45% 30%
HRA 8% 8% 8% 8%
Other Allowances 0% 0% 5% 15%
Vehicle Allowance Rs. 500 Rs.1100 2% 2.5%
House FurnitureAllowance Rs. 2500 Rs. 3000 Rs. 9500 Rs. 17000
Write a HTML document ("GetSal.html") to query the database for the total salary of the employee. The form has the following format. When the user types the ID and clicks on submit button, the request must be submitted to JSP page ("salary.jsp"). This JSP page must access the database, find the total salary of the employee and display in the bottom frame of the browser. The database is MSACCESS database for which imagine the "dsn" is created with the name "salary". ( 10 marks)
2. Design a servelet that displays current date and time. It should also display the date and time when the Servelet was last accessed. ( 8 marks)
3. a. Write different syntax rules of SOAP? ( 5 marks)
b. What are the different SOAP Fault Codes? ( 5 marks)
4. Write a JSP program which demonstrates the usage of java beans. ( 10 marks)
5. Write a short notes on any two of the following:
i. Stateless session bean.
ii. Stateful session bean.
iii. Message-driven bean. ( 12 marks)

END OF SECTION B

Section C : Applied Theory (20 Marks)
· This section consists of questions with serial number 6 - 7.· Answer all questions. · Marks are indicated against each question.· Do not spend more than 25 - 30 minutes on Section C.
6. Write briefly about the JSP lifecycle. ( 10 marks)
7. How do you perform URL Redirection
in servlets? Explain all the ways. ( 10 marks)

ganeshbala

Suggested Answers
Enterprise Java (MC335) : October 2008
Section A : Basic Concepts
Answer Reason
1. A We define servlet mapping in web.xml file.
2. B All servlets must implement the Servlet interface of package using javax.servlet.
3. D The Web server that executes the servlet creates an HttpServletRequest object and passes this to the servlet's service method (which, in turn, passes it to doGet or doPost).
4. B The client can access the servlet only if the servlet is installed on a server that can respond to servlet requests
5. B Java Networking Java 1.1 natively support. TCP
6. A Cookies can survive server crashes because they are stored on the client's hard disk.
7. D A cookie is a small file that a Web Server may send to the user's Web browser, which in turn saves it to the hard disk.
8. C HttpSession can be used to store client side user state information while avoiding any impact due to the users web browser configuration.
9. B Parameters are passed as name/value pairs in a get request.
10. C getBytes() against the HttpServletrequest object identifies the correct method a servlet developer should use to retrieve form data from the client provided to the doPost() method.
11. D JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage.
12. C It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment.
13. C To embedding Java code directly within the HTML markup of your JSP page Moving the code into JavaBeans and servlets.
14. A Code that deals with logic that is common across requests.
15. C Lookup the EJBs from within a servlet, delegating usage to specific JSP pages.
16. A JSP is the initia contact point for handling a web request in a Page-Centric architecture.
17. D The forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page.
18. B Using the action.
19. B JSP page is compiled into a servlet.
20. D When using scriptlets (that is code included within <% %>), the included code must have legal Java syntax. So the first statement must end with a semi-colon. The second statement on the other hand is a JSP expression. So it must not end with a semi colon.
21. A Java Server Pages.
22. B javax.ejb.EJBHome
23. D javax.ejb.EntityBean is used to embody business objects
24. C javax.ejb.SessionBean is used to embody application processing state information.
25. D javax.ejb.EJBObject interface must the enterprise bean implement so that an application can invoke its operations.
26. A An XML file format used by the container to learn about the attributes of a bean, such as transactional characteristics and access control is a deployement descriptor.
27. E For a stateless session bean there must be one per client as long as the client is executing the business logic and is the most scalable type of bean.
28. B construction,setSessionContext(),ejbCreate() is the order.
29. E For remote objects java passes objects by object copy and producing a serialized copy.
30. D To override a JSP files initialization method we must use this tags <%! %> for declaring the method.

ganeshbala

Question Paper
Enterprise Java (MC335) : July 2008
Section A : Basic Concepts (30 Marks)
· This section consists of questions with serial number 1 - 30.
· Answer all questions.
· Each question carries one mark.
· Maximum time for answering Section A is 30 Minutes.


1. Choose the statement that best describes the relationship between JSP and servlets:(a) Servlets are built on JSP semantics and all servlets are compiled to JSP pages for runtime usage
(b) JSP and servlets are unrelated technologies
(c) Servlets and JSP are competing technologies for handling web requests. Servlets are being superseded by JSP, which is preferred. The two technologies are not useful in combination
(d) JSPs are built on servlet semantics and all JSPs are compiled to servlets for runtime usage
(e) JSPs are built on servlet semantics and all servlets are compiled to JSP for runtime usage.

2. What is the benefit of using JavaBeans to separate business logic from presentation markup within the JSP environment?(a) It allows the JSP to access middleware
(b) It creates a cleaner role separation between the web-production team and the software development team, so that the web-production team can focus on presentation markup, while the software team can focus on building reusable software components for helping to generate dynamic displays
(c) It provides a dynamic markup environment, such that JavaBeans are integrated seamlessly with the template presentation content, in order to create the dynamic display for the client
(d) It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment
(e) It provides the system administrator with full access to the Java 2 platform Enterprise Edition.

3. Why is RequestDispatcher used to forward a request to another resource, instead of using a sendRedirect?(a) Redirects are no longer supported in the current servlet API
(b) Redirects are not a cross-platform portable mechanism
(c) The RequestDispatcher does not use the reflection API
(d) The RequestDispatcher does not require a round trip to the client, and thus is more efficient and allows the server to maintain request state
(e) All of the above.

4. Which alternative exists to embed Java code directly within the HTML markup of your JSP page?(a) Moving the code into your session manager
(b) Moving the code into scriptlets
(c) Moving the code into JavaBeans and servlets
(d) Moving the code into a transaction manager
(e) Moving the code into HTML.

5. What type of scriptlet code is better-suited to being factored forward into a servlet?(a) Code that deals with logic that is common across requests
(b) Code that deals with logic that is vendor specific
(c) Code that deals with logic that relates to database access
(d) Code that deals with logic that relates to client scope
(e) Code that deals with logic that relates to client specific.

6. Choose the statement that best describes how to connect JSP pages and Enterprise JavaBeans (EJBs).(a) Lookup the EJBs from within a JSP, but use the EJBs from within a basic JavaBean
(b) Lookup and use the EJBs from a separate business delegate. The JavaBeans that work with JSP pages are clients to these business delegates and know nothing about EJB specifics
(c) Lookup and use the EJBs from within a JSP page, but only as remote references
(d) Lookup the EJBs from within a servlet, delegating usage to specific JSP pages
(e) Look and use the EJBS from within a HTML page.

7. Are custom tags available in JSP 1.0? If not, how else might you implement iteration from within a JSP?(a) Yes, but the only tags available relate to database access
(b) No, to iterate over a collection of values, one must use scriptlet code
(c) No, but there is a standard tag that may be used
(d) Yes, but custom tags will not help developers create tags for use in iterating over a collection
(e) Yes, to iterate over a single value one must use html code.

8. What is the initial contact point for handling a web request in a Page-Centric architecture?(a) A JSP page
(b) A JavaBean
(c) A servlet
(d) A session manager
(e) A HTML bean.

9. What is the difference between doing an include or a forward with a RequestDispatcher?(a) The forward method transfers control to the designated resource, while the include method invokes the designated resource, substitutes its output dynamically in the display, and returns control to the calling page
(b) The two methods provide the same functionality, but with different levels of persistence
(c) The forward method is deprecated as of JSP 1.1 and the include method should be used in order to substitute portions of a dynamic display at runtime
(d) The include method transfers control to a dynamic resource, while the forward method allows for dynamic substitution of another JPS pages output, returning control to the calling resource
(e) The include method transfers control to a designated resource while the forward method invokes the designated resource.

10. What line of code below might be combined in the same JSP page with a validation guard (for example, <% bean.validationGuard(); %> ), in order to create an alternate flow of control for scenarios in which exceptions arise. The validationGaurd method might throw an exception, which should cause the flow of control to continue in another user-defined page (assume JSP 1.0).(a)
(b) <%@ page language="java" buffer="8k" %>
(c)
(d) <%@ page language="java" errorPage="errorPage.jsp" buffer="8k" %>
(e) <%@ page language="java" error="errorPage.jsp" buffer="8k" %>.

11. What does the EJB specification architecture define?I. Tansactional components.II. Distributed object components.III. Server-side components.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
(e) All (I), (II) and (III) above.

12. What executes EJB components?(a) A web server
(b) An application server
(c) An EJB container
(d) A database server
(e) A knowledge server.

13. What do enterprise beans use to communicate with the EJB container to get runtime context information?(a) The javax.ejb.EJBContext provided by the container
(b) A JNDI ENC context
(c) A javax.ejb.EJBHome object provided by the container
(d) A javax.ejb.EJBMetaData object provided by the container
(e) A java.ejb.MetaData object provided by the container.

14. Through which interface does an application create, find, and remove enterprise beans?(a) java.rmi.Remote
(b) javax.ejb.EJBHome
(c) javax.ejb.EJBObject
(d) javax.ejb.EntityBean
(e) javax.Home.ejb.

15. What type of enterprise bean is used to embody business objects?(a) javax.ejb.EnterpriseBean
(b) java.rmi.Remote
(c) javax.ejb.SessionBean
(d) javax.ejb.EntityBean
(e) javax.ejb.SessionlessBean.

16. What type of enterprise bean is used to embody application processing state information?(a) javax.ejb.EnterpriseBean
(b) javax.rmi.Remote
(c) javax.ejb.SessionBean
(d) javax.ejb.EntityBean
(e) javax.ejb.AttributeBean.

17. What interface must the enterprise bean implement so that an application can invoke its operations?(a) javax.ejb.EntityBean
(b) javax.ejb.EJBHome
(c) javax.ejb.EJBObject
(d) javax.rmi.Remote
(e) javax.Remote.rmi.

18. At what point precisely, in the life-cycle of a container-managed entity bean is supposed to be created?(a) Immediately prior to the execution of its ejbCreate() method
(b) Immediately after the execution of its ejbCreate() method
(c) After the CMP bean's data has been committed to the underlying persistent datastore
(d) During the execution of its ejbPostCreate() method
(e) During the execution of its ejbGetCreate() method.

19. What distinguishes a bean-managed persistent (BMP) enterprise bean from a container-managed persistent (CMP) enterprise bean?I. A BMP bean must implement the ejbLoad() and ejbStore() methods.II. A BMP bean can implement persistence to custom data stores such as legacy systems.III. A BMP bean is responsible for managing its own persistence to a persistent datastore.(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
(e) All (I), (II) and (III) above.

20. What is a deployment descriptor?(a) An XML file format used by the container to learn about the attributes of a bean, such as transactional characteristics and access control
(b) A method for transporting enterprise beans back and forth between systems
(c) An XML file used by enterprise bean clients to learn about the attributes of a bean, such as access control and transactional characteristics
(d) A format for bundling enterprise beans for delivery to customers
(e) An HTML format used by enterprise beans for delivery to customers.

21. What do you have to do to make an instance variable into a JavaBean property?(a) Declare the instance variable public and static
(b) Define a get method and a set method for the variable
(c) Drop the Bean into the BeanBox property sheet
(d) Declare the instance variable private and let the BeanBox define get and set methods for the variable
(e) Define a post method and a get method for the variable.

22. An application builder tool can analyze how JavaBeans work. Which mechanism does the tool use?(a) Persistence
(b) Method customization
(c) Introspection
(d) Event delegation
(e) Attribute Customization.

23. Properties control is "what aspects of a JavaBean"?(a) The communication between JavaBeans
(b) A JavaBean's appearance and behavior
(c) How a JavaBean is compiled and dropped into the BeanBox (or other tool)
(d) The tools you can use to customize a JavaBean
(e) The directory of a Java Beans.

24. JavaBean methods are all(a) Events
(b) Properties
(c) Event listeners
(d) Identical to methods of other Java classes
(e) Event Delegates.

25. A source Bean is a JavaBean that fires an event, while the Bean that receives the event is called a(a) Listener Bean
(b) Receiver Bean
(c) Enterprise JavaBean
(d) EventHandler Bean
(e) EventSource Bean.

26. When a JSP page is compiled, what is it turned into?(a) Applet
(b) Servlet
(c) Application
(d) Mailet
(e) Webpage.

27. If you want to override a JSP file's initialization method, within what type of tags must you declare the method?(a) <@ @>
(b) <%@ %>
(c) <% %>
(d) <%! %>
(e) .

28. Which of the following can not be used as the scope when using a JavaBean with JSP?(a) Application
(b) Session
(c) Request
(d) Response
(e) Page.

29. How can a servlet call a JSP error page?(a) This capability is not supported
(b) When the servlet throws the exception, it will automatically be caught by the calling JSP page
(c) The servlet needs to forward the request to the specific error page URL. The exception is passed along as an attribute named "javax.servlet.jsp.jspException"
(d) The servlet needs to redirect the response to the specific error page, saving the exception off in a cookie
(e) All of the above.

30. When using a JavaBean to get all the parameters from a form, what must the property be set to (??? in the following code) for automatic initialization?...(a) *
(b) All
(c) @
(d) =
(e) !=.

ganeshbala

END OF SECTION A
Section B : Problems (50 Marks)
· This section consists of questions with serial number 1 – 5.· Answer all questions. · Marks are indicated against each question.· Detailed workings should form part of your answer. · Do not spend more than 110 - 120 minutes on Section B.
1. Consider the following XHTML form:Implement a JSP page sum.jsp which computes the sum of the two numbers x and y. Generate valid XHTML and give an appropriate response if the input fields do not contain proper numbers. ( 10 marks)
2. Write a servlet that allows each user to start a string concatenating session.The servlet works by concatenating two strings : (1) the string newstring provided by the user as a request parameter; and (2) the string oldstring saved in a session attribute. When a new session is started the attribute oldstring should be initialized to "" (the empty string). The servlet should produce a simple HTML page that shows the resulting concatenated string.The servlet should also save the resulting concatenated string in the session attribute oldstring.Note: You can assume that both newstring and oldstring contain only plain ASCII characters. ( 10 marks)
3. Draw the structure of SOAP envelope and describe what does a SOAP message Contain? ( 10 marks)
4. Explain briefly on the following:
a. Entity Beans. ( 5 marks)
b. Session Beans. ( 5 marks)
c. Message Driven Beans. ( 5 marks)
5. What are the four major parts defined by OMA that makes a CORBA Installation? ( 5 marks)

END OF SECTION B
Section C : Applied Theory (20 Marks)
· This section consists of questions with serial number 6 - 7.· Answer all questions. · Marks are indicated against each question.· Do not spend more than 25 -30 minutes on Section C.
6. Describe briefly about the JSP lifecycle with a neat sketch. ( 10 marks)
7. What are the different CORBA services available? Explain briefly on each of the service. ( 10 marks)

END OF SECTION C

END OF QUESTION PAPER

Suggested Answers
Enterprise Java (MC335) : July 2008
Section A : Basic Concepts
Answer Reason
1. D Every JavaServer Pages (JSP) source page is compiled into a servlet before it is executed at runtime. < TOP >
2. B When large amounts of Java scriptlet code are mixed with HTML markup within a JSP page, not only do readability and reuse suffer, but often bugs are introduced as web-production team members, who may not be familiar with Java programming, need to modify the accompanying markup. Additionally, dependencies now exist among various teams competing for the same file, making the development process less efficient. < TOP >
3. D Doing an HTTP redirect requires a round-trip to the client. If this is not required, and the only desire is to forward the request to another resource, then this can be much more efficiently accomplished with the RequestDispatcher. Additionally, when using the dispatcher the state of the request object is maintained between resources, which will not be the case with the HTTP redirect. < TOP >
4. C Business logic is better contained in a JavaBean or a servlet that is owned by a software developer. When lots of Java code is embedded directly within the JSP page as scriptlets, the "cut-and-paste" mentality tends to prevail when it comes to code reuse. < TOP >
5. A Since the servlet is the initial contact point for each request, it is well-suited to handle logic that is common across multiple requests. A good example of this type of logic is an authentication check. < TOP >
6. B Using a business delegate reduces coupling between the presentation and business tiers. The presentation tier has no knowledge of the EJB implementation details, such as Java Naming and Directory InterfaceTM lookup. < TOP >
7. B Using Java scriptlets is the accepted method of doing iteration in JSP 1.0. In JSPTM 1.1, a custom tag may be used, which will hide the implementation details of the iteration code. < TOP >
8. A The term Page-Centric is used to describe an architecture where the initial contact point for the request is a JSP page. An example is shown visually below: < TOP >
9. A When the forward method is used, the invoking resource does not regain control. Multiple include invocations can be made from the same resource, while the invoking resource maintains execution control. < TOP >
10. D Error pages are invoked when there is an uncaught exception from within a particular page. In this case, we mention that the validationGaurd() method might throw an exception. If this exception is not caught within the page, then we vector control to errorPage, as stipulated in the attribute of the given page directive. < TOP >
11. E All of the above. < TOP >
12. C An EJB container. < TOP >
13. A The javax.ejb.EJBContext provided by the container. See The EJB Container < TOP >
14. B javax.ejb.EJBHome < TOP >
15. D javax.ejb.EntityBean < TOP >
16. C javax.ejb.SessionBean < TOP >
17. C javax.ejb.EJBObject < TOP >
18. B Immediately after the execution of its ejbCreate() method < TOP >
19. E All of the above. See Bean Managed Persistence < TOP >
20. A An XML file format used by the container to learn about the attributes of a bean, such as transactional characteristics and access control < TOP >
21. B By definition, JavaBean properties are declared as private variables. To allow other components and builder tools to access these properties, a Bean must define get and set methods for each property. See Creating a Simple Bean < TOP >
22. C Builder tools can analyze JavaBeans through the process of introspection. JavaBeans support introspection by adhering to specific rules, called design patterns, for naming Bean features. Each Bean has a related Bean information class, and this information class provides property, method, and event information about the Bean itself. A Bean information class implements a BeanInfo interface. The class explicitly lists the Bean features that are to be exposed to application builder tools. < TOP >
23. B By definition, a JavaBean's properties control its appearance and behavior. Because builder tools can introspect on a Bean to discover its properties and to expose them for manipulation, you can change a Bean's property at design time. See Properties < TOP >
24. D By definition, all JavaBean methods are identical to methods of other Java classes. Like other Java methods, Bean methods can be called by other Beans or via scripting languages. < TOP >
25. A Beans use events to communicate with other Beans. Source beans fire events, which means the Bean sends an event to another Bean. A Bean may receive an event, in which case it is considered a listener Bean. A listener Bean registers its interest in the event with the source Bean. < TOP >
26. B Compiled JSP pages are turned into Servlets. See JSP Architecture for more information on this translation phase. < TOP >
27. D Declarations are placed within a set of <%! %> tags. See Declarations. < TOP >
28. D Response is not a valid object scope for JavaBeans (or anything else). See Object Scopes. < TOP >
29. C D will get the browser to display the appropriate page, it just doesn't preserve the state information requiring an unnecessary round trip to the browser. C is the direct approach. < TOP >
30. A The * character is used for this. < TOP >

Section B : Problems
1. The main issue to deal with is malformed arguments; luckily Integer.parseInt(s) handles all that by throwing a NumberFormatException if s cannot be properly parsed to an integer. The cases where one of the arguments is missing are also addressed by the same logic, because null (as returned by getParameter) will not be parseable.<%! String sx,sy; %><%! int x,y; %><% sx = request.getParameter("x");sy = request.getParameter("y");try {x = Integer.parseInt(sx);y = Integer.parseInt(sy);%>The sum is <%= x+y %>.<%} catch (NumberFormatException e) {%>Illegal arguments!<%}%>< TOP >
2. import java.io.*;import javax.servlet.*;import javax.servlet.http.*;public class StringConcat extends HttpServlet {// Should be a doPost as method certainly has sideeffects.public void doPost(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException{response.setContentType("text/html");PrintWriter out = response.getWriter();out.println("");out.println("");out.println("");String newstring = request.getParameter("newstring");if(newstring == null) newstring = "";out.println("

");out.println("

You submitted the string:"+ newstring +".
");HttpSession session = request.getSession();String oldstring = "";synchronized(this) {if( session.isNew() ){out.println("

(New session started.)
");session.setAttribute("oldstring", oldstring);} elseoldstring = (String) session.getAttribute("oldstring");oldstring = oldstring.concat(newstring);session.setAttribute("oldstring", oldstring);}out.println("

The string now saved is:"+ oldstring + "
");out.println("");}public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException, ServletException {response.sendError(response.SC_METHOD_NOT_ALLOWED,"This service has sideeffects --- so only accepts POSTs.");}} < TOP >
3. SOAP Message StructureSOAP is an XML-based protocol for representing data. An XML document that's authored according to the SOAP constructs is normally called a SOAP envelope. The following figure shows the structure of the SOAP envelope. A SOAP message contains the following:The Envelope is the top element of the XML document. The Envelope element may contain namespace declarations as well as additional attributes that are namespace qualified. The Envelope element may contain additional subelements to Header and Body that are namespace qualified and must follow the Body element.The Header is a generic mechanism for adding features to a SOAP message in a decentralized manner without prior agreement between the communicating parties. SOAP defines a few attributes that can indicate who should deal with a feature and whether it's optional or mandatory. The Header element may be present in a SOAP message. If present, the element must be the first immediate child element of a SOAP Envelope element. The element may contain a set of namespace-qualified header entries, each being an immediate child element of the SOAP Header element.The Body is a container for mandatory information intended for the ultimate recipient of the message. SOAP defines one element for the body, which is the Fault element used for reporting errors. The Body element must be present in a SOAP message and must be an immediate child element of a SOAP Envelope element. It must directly follow the SOAP Header element if present. Otherwise, it must be the first immediate child element of the SOAP Envelope element. The element may contain a set of body entries that may be namespace qualified, each being an immediate child element of the Body element. < TOP >
4. Entity beansEntity beans represent and manipulate the persistent data of an application, providing an object-oriented view of data that are frequently stored in relational databases. This is an important advantage to users, because the underlying format in which data may well be stored in a database is via relational tables accessed through SQL queries and stores. Encapsulating this state behind an object isolates the users from the implementation details of how the state is represented in memory and in the persistent store: The entity bean is then responsible for loading the state from the store and saving it back later.As shown in the figure, it's much better for the user of a bean to be able to call a reserveSeat method on an airline-reservation object than have to deal with the persistent store directly (which will typically involve SQL) once the state is loaded into volatile memory – meaning that the entity bean has been activated—the application can manipulate the bean state. The state on persistent (stable) store will survive crashes unless there is a catastrophic failure of the persistent store, whereas the state within the entity bean will definitely be lost. All of the interactions between the bean and the data store are mediated by the container and hidden from the client. Another important point is that entity beans can be shared among multiple concurrent clients. Thus, in the example in figure, different users can be calling the reserveSeat method simultaneously. If concurrent data manipulation is not allowed by the application, the bean should use transactions to ensure data consistency. Two types of entity bean exist:· Bean-managed persistent (BMP)Container-managed persistent (CMP)Session beansSession beans, on the other hand, do not use persistent data and are instantiated on a per-client basis with an instance of a session bean available for use by only one client, in contrast to entity beans. In general, whereas an entity bean represents persistent data, a session ban performs calculations. Session beans are intended to encapsulate business logic. A session bean may be stateless, meaning that it does not maintain conversational state, or stateful, meaning that it maintains conversational state. Conversational state is needed to share state information across multiple requests from a client.Message-driven beans (MDB)Message-driven beans were introduced in the EJB 2.0 specification to provide asynchronous processing by acting as message-listeners for Java Messaging Service (JMS). A traditional request-response procedure call is termed synchronous because the requester waits for the response before proceeding. In an asynchronous model, the requester may perform other work before receiving the response.Like stateless session beans, MDBs do not maintain conversational state for clients, although instance variables of a message-driven bean can maintain state across multiple client messages. Unlike session and entity beans, MDBs have no direct client-interaction interface: Clients must interact with MDBs via JMS topics and queues.MDBs reside in an application server's EJB container and act as asynchronous message listeners. They can leverage all of the facilities afforded by the container, such as security and transactioning, while simultaneously supporting the JMS programming model for message consumers. Additionally, the MDB model can support concurrent processing of a stream of messages by means of container supplied pooling of bean instances. < TOP >
5. The OMA defines four major parts that can make up a CORBA installation: 1. The Object Request Broker acts as a software bus for objects to intercommunicate. 2. CORBAServices define system-level services that are added on to the ORB, such as Security, Naming, and Transactions. 3. CORBAFacilities define application-level services, such as compound documents and other vertical facilities. 4. Business Objects describe real-world objects and applications, such as an Airplane or a BankAccount. < TOP >
Section C: Applied Theory
6. The JSP engine uses three methods to manage the lifecycle of a JSP page and its generated servlet.The heart of the JSP page is processed using a generated method called _jspService. This is created and managed by the JSP engine itself. The _jspService method represents the bulk of the JSP page, handling all requests and responses. Two other methods, jspInit() and jspDestroy(), are designed to be overridden by the JSP author. In fact these methods do not exist unless specifically created by the JSP author. They play a special role in managing the lifecycle of a JSP page.jspInit()method signature: void jspInit()jspInit() is a method that is run only once when the JSP page is first requested. jspInit() is guaranteed to be completely processed before any single request is handled. It is effectively the same as the init() method in Java Servlets and Java Applets.jspInit() allows the JSP author a means to create or load objects that may be needed for every request. This can be useful for loading state information, creating database connection pools, and any task that only needs to happen once when the JSP page is first started.jspDestroy()method signature: void jspDestroy()The server calls the jspDestroy() method when the Servlet is unloaded from the JVM. It is effectively the same as the destroy() method in Java Servlets and Java Applets.Unlike jspInit() this method is not guaranteed to execute. The server will make its best effort attempt to run the method after each thread. Since this method occurs at the end of processing, there are situations—such as the server crashing—where jspDestroy() may not be executed.jspDestroy() allows the JSP author a means to execute code just before the Servlet has finished. This is commonly used to free up resources or close connections that are still open. It can also be useful to store state information or other information that should be stored between instances.JSP Lifecycle overviewOn first request or precompile jspInit() will be called, at which point the page is "running" waiting for requests. Now _jspService handles most transactions, picking up requests, running threads through, and generating responses. Finally, when a signal is received to shutdown the jspDestroy() method is called. The overall lifecycle of a JSP page is shown in the following figure. < TOP >
7. CORBA ServicesAnother important part of the CORBA standard is the definition of a set of distributed services to support the integration and interoperation of distributed objects. As depicted in the graphic below, the services, known as CORBA Services or COS, are defined on top of the ORB. That is, they are defined as standard CORBA objects with IDL interfaces, sometimes referred to as "Object Services." There are several CORBA services. Below is a brief description of each:Service Description
Object life cycle Defines how CORBA objects are created, removed, moved, and copied
Naming Defines how CORBA objects can have friendly symbolic names
Events Decouples the communication between distributed objects
Relationships Provides arbitrary typed n-ary relationships between CORBA objects
Externalization Coordinates the transformation of CORBA objects to and from external media
Transactions Coordinates atomic access to CORBA objects
Concurrency Control Provides a locking service for CORBA objects in order to ensure serializable access
Property Supports the association of name-value pairs with CORBA objects
Trader Supports the finding of CORBA objects based on properties describing the service offered by the object
Query Supports queries on objects

ganeshbala

M.C.A Computer Aplications Enterprise Java (MC335) : April 2008 Question paper

Enterprise Java (MC335) : April 2008
Section A : Basic Concepts (30 Marks)
? This section consists of questions with serial number 1 -
30.
? Answer all questions.
? Each question carries one mark.
? Maximum time for answering Section A is 30 Minutes.
1. Which is not related to Java Language?
(a) Multithreading
(b) Class overloading
(c) Remote method invocation
(d) Serialization
( e) Interface.
2. The main motive behind server-side technology is
(a) To provide input validation
(b) To provide dynamic contents
(c) To provide static contents
(d) To provide animated contents
( e) To provide computation at client-side.
3. What is true for HTTP protocol?
I. It is a stateless protocol.
II. It can maintain state of the Web.
III. It is fundamental to the Web.
(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
( e) Both (I) and (III) above.
4. Which is not true for servlet?
(a) It is persistent
(b) Platform independent
(c) High performance
(d) Browser executes the code
( e) It is a class.
5. Which scope has highest visibility for a Java bean in JSP?
(a) Page
(b) Session
(c) Request
(d) Application
( e) Global.
6. Which tag is used to transfer processing to another JSP page?
(a)
(b)
(c)
(d)
( e) All (a), (b), (c) and (d) above.
7. Which object is used to forward the request processing from one servlet to another?
(a) ServeltContext
(b) ServletConfig
(c) RequestDispatcher
(d) ResponseDispatcher
( e) ResponseRedirect.
2
8. Which is not true for JSP technology?
(a) Persistent
(b) Platform independent
(c) High performance
(d) Browser executes the code
(e) Uses servlet API.
9. Which scope is default for a Java bean in JSP?
(a) Page
(b) Session
(c) Request
(d) Application
( e) Global.
10. Which method of the request object is used to extract values of the input fields in a form
when it is submitted?
(a) getParameter
(b) getParameterNames
(c) getValues
(d) putValues
( e) getParameters.
11. Which of the following is used to redirect the response from a servlet to a JSP page?
(a) response.sendRedirect()
(b) request.sendRedirect()
(c) request.forward()
(d) response.forward()
( e) request.dispatch().
12. Which method of the servlet is called once in its life?
(a) init()
(b) doPost()
(c) doGet()
(d) service()
( e) All (a), (b), (c) and (d) above.
13. Which allows substitution of code to occur at the translation time in a JSP page?
(a) Tag
(b) <@ include> directive
(c) <@ page > directive
(d) Declaration block
( e) @include.
14. Which is not true for Java Bean?
(a) It is a reusable component
(b) It implements serializable interface
(c) It has zero-argument constructor
(d) It is a distributed component
( e) All (a), (b), (c) and (d) above.
15. Which property of Java Bean does not represent a single value?
I. Simple property
II. Boolean property
III. Indexed property
(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
( e) Both (II) and (III) above.
16. Which is true for tag in JSP page?
(a) Locates a bean instance
(b) Stores object reference of the bean in a variable
(c) Creates an instance if fails to locate the bean instance
(d) Executes the body of the tag
( e) All (a), (b), (c) and (d) above.
3
17. Which is not an implicit object in JSP?
(a) Request
(b) Response
(c) Session
(d) Vector
( e) Out.
18. Which of the following is not an approach for state maintenance in Web applications?
(a) Hidden Form Field
(b) URL Rewriting
(c) Cookies
(d) HTTP Session Object
( e) JDBC.
19. Which of the following is used to modify the property of a Java bean in a JSP page?
(a)
(b)
(c)
(d)
( e) .
20. Which method of the servlet is called when it is destroyed?
(a) init()
(b) doPost()
(c) doGet()
(d) service()
( e) destroy().
21. Which of the following object is a parameter to init() of the servlet?
(a) ServletContext
(b) ServletConfig
(c) HttpRequest
(d) HttpResponse
( e) RequestDispatcher.
22. What is the default format of the response generated from a servlet?
(a) HTML
(b) XML
(c) Text
(d) Java
( e) JSP.
23. What is the return type of the doPost() of servlet?
(a) String
(b) HttpResponse
(c) void
(d) Vector
( e) HttpRequest.
24. Which of the following is not an element in a JSP page?
(a) Directives
(b) Declaration block
(c) Scriptlets
(d) Expressions
( e) Definition.
25. Which of the following is used to import Java packages in a JSP page?
(a) Include directive
(b) Import directive
(c) Page directive
(d) Taglib directive
( e) Using directive.
4
26. Which JDBC driver type provides the best performance?
(a) Type-1
(b) Type-2
(c) Type-3
(d) Type-4
(e) All (a), (b), (c) and (d) above.
27. Which JDBC driver is bundled with Sun's JDK?
(a) Type-1
(b) Type-2
(c) Type-3
(d) Type-4
( e) All (a), (b), (c) and (d) above.
28. What is not true for JSP?
(a) It is a server-side technology
(b) It is a client-side technology
(c) It is executed by the browser
(d) Both (b) and (c)
( e) Both (a) and (c).
29. Immediate base class for HttpServlet is
I. Object.
II. GenericServlet.
III. Servlet.
(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
( e) Both (II) and (III) above.
30. Which of the following interfaces does HttpServlet implement?
I. Servlet.
II. ServletConfig.
III. ServletContext.
(a) Only (I) above
(b) Only (II) above
(c) Only (III) above
(d) Both (I) and (II) above
( e) Both (II) and (III) above.
END OF SECTION A
5
Section B : Problems (50 Marks)
? This section consists of questions with serial number 1 – 5 .
? Answer all questions.
? Marks are indicated against each question.
? Detailed workings should form part of your answer.
? Do not spend more than 110 - 120 minutes on Section B.
1. Write a servlet code which tracks the number of visits for each unique visitor.
i. If this is a first time visit, the servlet creates an accessCount Integer variable
and assigns it to the Session.
ii. If the user has visited before, the servlet extracts the accessCount variable,
increments it, and assigns it to the Session.
iii. Servlet also displays basic information regarding the session, including
creation time and time of last access. ( 10 marks)
2. What is a Java Bean? Mention its advantages. ( 10 marks)
3.
What does the above figure demonstrates on? Explain in detail about the state of an
entity bean? ( 10 marks)
4. What does the given figure depict and describe briefly on each and every component
in the given figure.
( 10 marks)
5. Explain about Web Services Deployment Descriptor. ( 10 marks)
END OF SECTION B
6
Section C : Applied Theory (20 Marks)
? This section consists of questions with serial number 6 - 7.
? Answer all questions.
? Marks are indicated against each question.
? Do not spend more than 25 - 30 minutes on Section C.
6. Explain briefly the advantages of servlets. ( 10 marks)
7. Write a short note on the following:
a. jsp:plugin Element. ( 6 marks)
b. jsp:fallback Element. ( 4 marks)

ganeshbala

Suggested Answers
Enterprise Java (MC335) : April 2008
Section A : Basic Concepts
Answer Reason
1. B There is no class overloading in java.
2. B The main motive behind server side technology is to provide dynamic contents.
3. E HTTP protocol is a stateless protocol and it is fundamental to the web.
4. D Browser doesn't execute the code.Webserver executes the code.
5. D Application has highest visibility for a java bean in jsp.
6. B is used to transfer processing to another JSP page.
7. C Request Dispatcher is used to forward the request processing from one servlet to
another.
8. D browser doesnot execute the code for JSP technology.
9. A Page scope is default for a java bean in JSP
10. A getParameter()method of the request object is used to extract values of the input fields
in a from when it is submitted
11. A response.sendRedirect()used to redirect the response from a servlet to a JSP page
12. A init() method of the servlet is called once in its life.
13. B <@ include> directive allows substitution of code to occur at the translation time in a
JSP page
14. D java bean is not a distributed component.
15. C Indexed property of Java Bean does not represent a single value
16. E All of the above are true for tag in JSP page
17. D Vector is is not an implicit object in JSP
18. E JDBC is not an approach for state maintenance in Web applications
19. A is used to modify the property of a Java bean in a JSP page
20. E destroy() method of the servlet is called when it is destroyed.
21. B ServletConfig object is a parameter to init() of the servlet.
22. A HTML is the default format of the response generated from a servlet
23. C void is the return type of the doPost() of servlet
24. E Definition is not an element in a JSP page
25. C Page directive is used to import Java packages in a JSP page
26. D Type-4 provides the best performance
27. A Type-1 is bundled with suns jdk.
28. D Jsp is not a client side technology and it isnot executed by the browswer
29. B Immediate base class for HttpServlet is Generic Servlet.
30. D Servlet and ServletConfig interfaces implement HttpServlet
8
Section B : Problems
1. import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.net.*;
import java.util.*;
public class ShowSession extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String title = "Session Tracking Example";
HttpSession session = request.getSession(true);
String heading;
Integer accessCount =
(Integer)session.getAttribute("accessCount");
if (accessCount == null) {
accessCount = new Integer(0);
heading = "Welcome, Newcomer";
} else {
heading = "Welcome Back";
accessCount = new Integer(accessCount.intValue() + 1);
}
session.putAttribute("accessCount", accessCount);
out.println(ServletUtilities.headWithTitle(title) +
"\n" +
"
" + heading + "
\n" +
"
Information on Your Session:
\n" +
"\n" +
"\n" +
" \n" +
" \n" +
" \n" +
" \n" +
" "+
"
Info Type   Value\n" +
"
ID\n" +
"    " + session.getId() + "\n" +
"
Creation Time\n" +
"    " +
new Date(session.getCreationTime()) + "\n" +
"
Time of Last Access\n" +
"    " +
new Date(session.getLastAccessedTime()) + "\n" +
"
Number of Previous Accesses\n" +
"    " + accessCount + "\n" +
"
\n" +
"");
9
}
/** Handle GET and POST requests identically. */
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
2. A Java Bean is a software component that has been designed to be reusable in a variety of
different environments. There is no restriction on the capability of a Bean. It can perform a
simple function, such as checking the spelling of a document, or a complex function, such as
forecasting the performance of a stock portfolio. A bean may be visible to an end user. One
example of this is a button on a graphical user interface. A Bean may also be invisible to a user.
Software to decode a stream of multimedia information in real time is an example of this type of
building block. Software to generate a pie chart from a set of data points is an example of a Bean
that can execute locally. However, a Bean that provides real-time price information from a stock
or commodities exchange would need to work in cooperation with other distributed software to
obtain its data.
Advantages of Java Beans:
? Software component architecture provides standard mechanisms to deal with software
building blocks. The following list enumerates some of the specific benefits that Java
technology provides for a component developer:
? A Bean obtains all the benefits of Java's "write-once, run-anywhere" paradigm.
? The properties, events, and methods of a Bean that are exposed to an application builder
tool can be controlled.
? A Bean may be designed to operate correctly in different locales, which makes it useful in
global markets.
? Auxiliary software can be provided to help a person configure a Bean. This software is only
needed when the design-time parameters for that component are being set. It does not need
to be included in the run-time environment.
? The configuration settings of a Bean can be saved in persistent storage and restored at a
later time.
? A Bean may register to receive events from other objects and can generate events that are
sent to other objects.
3. The following figure illustrates what happens when a new client invocation arrives.
When the pool of bean instances is created, each bean is given a reference to a
javax.ejb.EJBContext instance by the container. Recall that it is through this context that the
bean can obtain information on, and interact with, its environment.
The code fragment below shows how an EJB for an airline reservation application might be
implemented. The setEntityContext method is called by the container at initialization time.
public AirlineBean implements EntityBean
{
public void setEntityContext(EntityContext ctx) throws
RemoteException
{
myContext = ctx;
myEnvironment = ctx.getEnvironment();
}
public EntityContext myContext;
public Properties myEnvironment;
}
Initially all that exists is the EJB home object that the client can use to obtain a remote interface
to the bean. The container then creates the corresponding EJB object, which is empty, in that it
10
has not been assigned a bean instance.
As shown in the following figure, once created, the EJB object is assigned any instance from the
pool. That instance moves from the pooled state to the ready state. At this point the enterprise
bean can receive invocations from the client on its business logic by means of the remote
interface. The container can manage this bean further—for its persistence or transaction
requirements, for example.
At any given time, an entity bean is in one of the following states:
Nonexistence— The bean has not yet been instantiated in this state.
Pooled— The bean has been instantiated by the container in this state, but has not been
associated with any particular EJB object.
Ready— The instance has been associated with an EJB object in this state, and is ready to be
used by a client.
A logical instance pool may exist for each type of bean (each class). To create an instance pool,
the container generates a number of instances of the class and places them within the pool until
they are needed. The initial size of the pool will be vendor-specific. However, your favorite
application-server implementation may enable the system administrator to configure the size of
the pool at runtime to improve performance.
As clients make requests on the business logic, the container assigns instances from the pool.
Because all instances in the pool are equivalent, any instance may be selected to service a
particular client request. Once the EJB object no longer requires the bean instance, the instance
is returned automatically to the pool. Obviously, the initial size of the pool may be inadequate for
the throughput of client requests. In this case the container may increase and/or decrease the size
of the pools to better suit the runtime environment.
4. ? Object -- This is a CORBA programming entity that consists of an identity, an interface,
and an implementation, which is known as a Servant.
? Servant -- This is an implementation programming language entity that defines the
operations that support a CORBA IDL interface. Servants can be written in a variety of
languages, including C, C++, Java, Smalltalk, and Ada.
? Client -- This is the program entity that invokes an operation on an object implementation.
Accessing the services of a remote object should be transparent to the caller. Ideally, it
should be as simple as calling a method on an object, i.e., obj->op(args). The remaining
components in Figure 2 help to support this level of transparency.
? Object Request Broker (ORB) -- The ORB provides a mechanism for transparently
communicating client requests to target object implementations. The ORB simplifies
distributed programming by decoupling the client from the details of the method
invocations. This makes client requests appear to be local procedure calls. When a client
invokes an operation, the ORB is responsible for finding the object implementation,
transparently activating it if necessary, delivering the request to the object, and returning
any response to the caller.
? ORB Interface -- An ORB is a logical entity that may be implemented in various ways
(such as one or more processes or a set of libraries). To decouple applications from
implementation details, the CORBA specification defines an abstract interface for an ORB.
This interface provides various helper functions such as converting object references to
strings and vice versa, and creating argument lists for requests made through the dynamic
invocation interface described below.
11
? CORBA IDL stubs and skeletons -- CORBA IDL stubs and skeletons serve as the ``glue''
between the client and server applications, respectively, and the ORB. The transformation
between CORBA IDL definitions and the target programming language is automated by a
CORBA IDL compiler. The use of a compiler reduces the potential for inconsistencies
between client stubs and server skeletons and increases opportunities for automated
compiler optimizations.
? Dynamic Invocation Interface (DII) -- This interface allows a client to directly access the
underlying request mechanisms provided by an ORB. Applications use the DII to
dynamically issue requests to objects without requiring IDL interface-specific stubs to be
linked in. Unlike IDL stubs (which only allow RPC-style requests), the DII also allows
clients to make non-blocking deferred synchronous (separate send and receive operations)
and oneway (send-only) calls.
? Dynamic Skeleton Interface (DSI) -- This is the server side's analogue to the client side's
DII. The DSI allows an ORB to deliver requests to an object implementation that does not
have compile-time knowledge of the type of the object it is implementing. The client
making the request has no idea whether the implementation is using the type-specific IDL
skeletons or is using the dynamic skeletons.
? Object Adapter -- This assists the ORB with delivering requests to the object and with
activating the object. More importantly, an object adapter associates object
implementations with the ORB. Object adapters can be specialized to provide support for
certain object implementation styles (such as OODB object adapters for persistence and
library object adapters for non-remote objects).
5. Servlet endpoint Web services are packaged as standard WAR files, and EJB endpoints are
packaged as EJB JAR files. Both EJB and servlet endpoint-based Web services are required to
include the Web service deployment descriptor, webservices.xml, in the META-INF or WEBINF
directories, respectively. The following figure shows the high-level structure of this file:
Each webservice-description element describes a Web service packaged in the WAR or EJB
module. The following figure shows the mandatory children for this element:
This example has the following parts:
webservice-description-name: This name identifies a collection port components associated
with a WSDL file and JAX-RPC mapping.
wsdl-file: This specifies the name and location of the WSDL file within the packaged module.
jaxrpc-mapping-file: This specifies the name and location of the file that describes the mapping
between the Java interfaces used by the application and the WSDL artifacts within the packaged
12
module.
port-component: This element associates a WSDL port with the JAX-RPC end-point interface
and implementation.
The following figure shows the mandatory children for the port-component element:
port-component-name: This is a unique name associated with the port component.
wsdl-port: This element specifies the namespace URI and local name of the WSDL port for
which this port component is defined.
service-endpoint-interface: This defines the fully qualified name of the service endpoint
interface.
service-impl-bean: This element defines the service implementation bean. For EJB endpoints
the ejb-link should be used to specify the name of the EJB as defined in ejb-jar.xml for which the
port component is defined. For servlet endpoints, the servlet-link should be used to specify the
name of the servlet that will accept the calls for this port component as defined in the web.xml
file. During packaging, the servlet class for this servlet should be the fully qualified name of the
service implementation bean. However, during deployment the container will generate a servlet
that will accept the requests on behalf of the service implementation bean.
handler: Handlers are components similar to servlet filters that can preprocess and postprocess
requests and responses both on the client and server side.
Section C: Applied Theory
6. Servlets have six main advantages:
? Efficient
? Convenient
? Powerful
? Portable
? Secure
? Inexpensive
Efficient:
? For each browser request, the servlet spawns a light weight thread.
? This is faster and more efficient that spawning a new operating system process.
? Hence, servlets have better performance and better scalability than traditional CGI.
Convenient:
? Servlets include built-in functionality for:
? Reading HTML form data
? Handling cookies
? Tracking user sessions
? Setting HTTP headers
? Java is object oriented
Powerful: Servlets can talk directly to the web servers.
? Multiple servlets can share data:
? Particularly important for maintaining database connections.
13
? Includes powerful techniques for tracking user sessions.
Portable:
? One of the advantages of Java is its portability across different operating systems.
? Servlets have the same advantages.
? You can therefore write your servlets on Windows, then deploy them on UNIX.
? You can also run any of your servlets on any Java-enabled web server, with no code
changes.
Secure:
? Traditional CGI programs have a number of known security vulnerabilities.
? Hence, you usually need to include a separate Perl/CGI module to supply the
necessary security protection.
? Java has a number of built-in security layers.
? Hence, servlets are considered more secure than traditional CGI programs.
? Inexpensive: You can download free servlet kits for development use.
? You can therefore get started for free!
? Nonetheless, production strength servlet web servers can get quite expensive.
7. a. The jsp:plugin element instructs the server to build a tag appropriate for applets that
use the plug-in. The simplest way to use jsp:plugin is to supply four attributes:
type, code, width, and height.
code="MyApplet.class"
width="475" height="350">

The jsp:plugin element has a number of other optional attributes. Most,
but not all, parallel attributes of the APPLET element. Here is a full list.
? type
For applets, this attribute should have a value of applet. However, the Java Plug-In
also permits you to embed JavaBeans elements in Web pages. Use a value of bean in
such a case.
? code
This attribute is used identically to the CODE attribute of APPLET, specifying the toplevel
applet class file that extends Applet or JApplet. Just remember that the name
code must be lower case with jsp:plugin (since it follows XML syntax), whereas
with APPLET, case did not matter (since HTML attribute names are never case
sensitive).
? width
This attribute is used identically to the WIDTH attribute of APPLET, specifying the width
in pixels to be reserved for the applet. Just remember that you must enclose the value in
single or double quotes.
? height
This attribute is used identically to the HEIGHT attribute of APPLET, specifying the
height in pixels to be reserved for the applet. Just remember that you must enclose the
value in single or double quotes.
b. The jsp:fallback element provides alternative text to browsers that do not support
OBJECT or EMBED. You use this element in almost the same way as you would use
alternative text placed within an APPLET element.

code="MyApplet.class"
width="475" height="350">

Error: this example requires Java.