Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

IMP FAQ’s related to J2EE:

1. Why Beans are used in J2EE architecture instead of writing all the code in jsp's?

In order to separate the Business Logic and presentation logic beans are used. We write the business logic in the Beans. Where there is a change in business processes we have to modify only the bean code not jsp code and vice versa.

2. Explain MVC (Model-View-Controller) architecture?

MVC: - In model view controller design pattern, the software has split into 3 pieces.

MODEL: Responsible for Managing Data. The business logic (the core business transactions and processing), necessary to accomplish the goal of the interaction (calculations, queries, and / or updates to a database, etc). Business logic should be separated from UI logic. This makes it possible to have different clients (for ex browser and GUI) using the same beans. Separating the 2 also makes the business components easier to re-use, maintain, and update or change.

Ex. Java Beans

VIEW: Responsible for generating the views. It involves the presentation layout (the actual HTML output), for the result of the interaction. For HTML clients, this can be done using JSP.

Ex: JSP

CONTROLLER: Responsible for user interactions & co-ordinate with MODEL &VIEW. It is the Presentation logic (the logical connection between the user and EJB services), necessary to process the HTTP request, control the business logic, and select an appropriate response. This can be provided by Java Servlets or Session Beans.



Application servers used for enterprise solutions, web servers are used middle tier web applications.

Web servers are used for running web applications, the features are very less to compare application server the application server is specific to application. And it can run all the applications including web application.

Ex:- web-logic, web-sphere, Jbose.

All are providing the more features than web server like tomcat.

4. Which bean can be called as Multi-Threaded bean?

Stateless Session Bean can be called as Multi-Threaded bean as for every request of users is handled by creating a new threaded for the same object.

5. Difference between SAX and DOM?

SAX stands for Simple API for XML. It is a standard interface for event based XML parsing. Programmers provide handlers to deal with different events as the Document is passed.

If we use SAX API to pass XML documents have full of control over what happens when the event occurs as result, customizing the parsing process extensively. For example a programmer might decide to stop an XML document as soon as the parser encounters an error that indicate that the document is invalid rather than waiting until the document is parsed. Thus improve the performance.

DOM stands for Document Object Model. DOM reads an xml document into memory and represents as it as tree. Each node of tree represents a particular piece of data from the original document. The main drawback is that the entire xml document has to be read into memory for DOM to create the tree which might decrease the performance of an application as the xml document get larger.

6. What is difference between stateless and state full session beans?

Stateless:

1) Stateless session bean maintains across method and transaction

2) The EJB server transparently reuses instances of the Bean to service different clients at the per-method level (access to the session bean is serialized and is 1 client per session bean per method.

3) Used mainly to provide a pool of beans to handle frequent but brief requests. The EJB server transparently reuses instances of the bean to service different clients.

4) Do not retain client information from one method invocation to the next. So many require the client to maintain on the client side which can mean more complex client code.

5) Client passes needed information as parameters to the business methods.6) Performance can be improved due to fewer connections across the network.

Stateful:

1) A stateful session bean holds the client session's state.

2) A stateful session bean is an extension of the client that creates it.

3) Its fields contain a conversational state on behalf of the session object's client. This state describes the conversation represented by a specific client/session object pair.

4) Its lifetime is controlled by the client.

5) Cannot be shared between clients.


7. What is a Servlet Context? How do you get it?

ServletContext is also called as application object. And this can be used for logging (stores some kind of information) getting context parameters, getting the request dispatcher and storing the global data.

We can get the ServletContext obj using ServletContext.

i.e. ServletContext sc = getServletContext ();

8. What is Servlet Config? How do you get it?

ServletConfig can be used to get the initialization Parameters, to get the reference to the ServletContext. There can be multiple ServletConfig objects in a web application. Each servlet has one Config object.

The configuration information is:

Servlet name, initialization parameters servlet context object.

9. What is Request Dispatcher? How do you get it?

The name itself reveals that it is used to dispatch the control to requesting resource. It is an interface used to include any resource with in our servlet or forward the controller to any other resource. It contains two methods.

Forward (“---url”);

Include (“---url”);

For getting this we have a method in servlet context interface. So we can get it by servlet context object

sc.getRequestDispatcher ();



This post first appeared on Web Applications Development | Custom Web Applicat, please read the originial post: here

Share the post

IMP FAQ’s related to J2EE:

×

Subscribe to Web Applications Development | Custom Web Applicat

Get updates delivered right to your inbox!

Thank you for your subscription

×