ANSWER
Java 2 Platform, Enterprise Edition (J2EE) is a platform that enables solutions for developing, deploying and managing multi-tier server-centric applications. J2EE utilizes Java 2 Platform, Standard Edition to extend a complete, stable, secure, fast Java platform to the enterprise level. It delivers value to the enterprise by enabling a platform which significantly reduces the cost and complexity of developing multi-tier solutions, resulting in services that can be rapidly deployed and easily enhanced
ANSWER
What are the main benefits of J2EE?
ANSWER
The primary technologies in J2EE are: Enterprise JavaBeansTM, JavaServer PagesTM, servlets, the Java Naming and Directory InterfaceTM (JNDI), the Java Transaction API (JTA), CORBA, and the JDBCTM data access API.
ANSWER
Enterprise JavaBeans (EJB) technology is the basis of J2EE. EJB technology provides the scaleable architecture for executing business logic in a distributed computing environment. J2EE makes the life of an enterprise developer easier by combining the EJB component architecture with other enterprise technologies to solutions on the Java platform for seamless development and deployment of server side applications.
ANSWER
ISVs need J2EE because it gives them a blueprint for providing a complete enterprise computing solution on the Java platform. Enterprise developers need J2EE because writing distributed business applications is hard, and they need a high-productivity solution that allows them to focus only on writing their business logic and having a full range of enterprise-class services to rely on, like transactional distributed objects, message oriented middleware, and naming and directory services
ANSWER
A full compatibility test suite will be available when the reference implementation ships. This test suite will test compatibility across Enterprise JavaBeans technology, servlets and JavaServer Pages technology.
ANSWER
The J2EETM Blueprints are the best practices philosophy for the design and building of J2EE-based applications. The design guidelines document provides 2 things. First, it provides the philosophy of building n-tier applications on the Java 2 platform. Second, it provides a set of design patterns for designing these applications, as well as a set of examples or recipes on how to build the applications.
ANSWER
The J2EE application programming model has qualified as part of the Sun BluePrintsTM best practices program, and has been renamed the "J2EETM Blueprints"
ANSWER
The purpose of the reference implementation is to validate the specifications. In short, it is to prove that the specifications can be implemented.
ANSWER
We do not allow the binary reference implementation to be deployed or redistributed at the request of our partners. The J2EE reference implementation is essentially a full-featured application server. To make it available on the market would provide a product that competes with the companies that we want to adopt the technology. In this light, we set up the licensing terms to honor this request.
ANSWER
XML is an essential component in the J2EE platform. J2EE will provide a framework for business-to-business data interchange using XML. Currently, JavaServer Pages framework can be used to generate and consume XML between servers or between server and client. In addition, Enterprise JavaBeans component architecture uses XML to describe its deployment properties, giving Enterprise JavaBeans data portability in addition to its code portability. For more info, see http://java.sun.com/xml/.
ANSWER
No. JavaBeans components are not considered J2EE components by the J2EE specification. They are written to manage the data flow between an application client or applet and components running on the J2EE server or between server components and a database. JavaBeans components written for the J2EE platform have instance variables and get and set methods for accessing the data in the instance variables. JavaBeans components used in this way are typically simple in design and implementation, but should conform to the naming and design conventions outlined in the JavaBeans component architecture.
ANSWER
No. Static HTML pages and applets are bundled with web components during application assembly, but are not considered web components by the J2EE specification. Even the server-side utility classes are not considered web components, either.
ANSWER
J2EE Web components can be either servlets or JSP pages. Servlets are Java programming language classes that dynamically process requests and construct responses. JSP pages are text-based documents that execute as servlets but allow a more natural approach to creating static content.
ANSWER
Containers are the interface between a component and the low-level platform specific functionality that supports the component. Before a Web, enterprise bean, or application client component can be executed, it must be assembled into a J2EE application and deployed into its container.
ANSWER
A container is a runtime support of a system-level entity. Containers provide components with services such as lifecycle management, security, deployment, and threading.
ANSWER
Servlet and JSP containers are collectively referred to as Web containers. It manages the execution of JSP page and servlet components for J2EE applications. Web components and their container run on the J2EE server.
ANSWER
It manages the execution of enterprise beans for J2EE applications. Enterprise beans and their container run on the J2EE server.
ANSWER
IManages the execution of applets. Consists of a Web browser and Java Plugin running on the client together.
ANSWER
J2EE components are packaged separately and bundled into a J2EE application for deployment. Each component, its related files such as GIF and HTML files or server-side utility classes, and a deployment descriptor are assembled into a module and added to the J2EE application. A J2EE application is composed of one or more enterprise bean,Web, or application client component modules. The final enterprise solution can use one J2EE application or be made up of two or more J2EE applications, depending on design requirements. A J2EE application and each of its modules has its own deployment descriptor. A deployment descriptor is an XML document with an .xml extension that describes a component’s deployment settings.
ANSWER
A thin client is a lightweight interface to the application that does not have such operations like query databases, execute complex business rules, or connect to legacy applications.
ANSWER
Following are the types of J2EE clients: Applets Application clients Java Web Start-enabled rich clients, powered by Java Web Start technology. Wireless clients, based on Mobile Information Device Profile (MIDP) technology.
ANSWER
A container is the interface between a component and the low-level platform specific functionality.The applications such as EJB component must be assembled and deployed on the J2EE container before executing. In other words A J2EE container is a run-time environment for Enterprise Java Beans, Java Server Pages, Servlets, etc. It provides basic functions like security, life cycle management, transaction management, and deployment services. J2EE containers are generally supplied by a J2EE server. Container is a runtime entity that provides services to specialized Java components
ANSWER
An application Client is a J2EE component that run on the client. An application is used to contain a full-function client non Web-based Java application that connects to the J2EE resources defined in the server.
ANSWER
The J2EE Connector API is used by J2EE tools vendors and system integrators to create resource adapters that support access to enterprise information systems that can be plugged into any J2EE product. Each type of database or EIS has a different resource adapter. Note: A resource adapter is a software component that allows J2EE application components to access and interact with the underlying resource manager. Because a resource adapter is specific to its resource manager, there is typically a different resource adapter for each type of database or enterprise information system.
ANSWER
A Web page development framework. Struts combines Java Servlets, Java Server Pages, custom tags, and message resources into a unified framework. It is a cooperative, synergistic platform, suitable for development teams, independent developers, and everyone between.
ANSWER
Struts is hosted by the Apache Software Foundation(ASF) as part of its Jakarta project, like Tomcat, Ant and Velocity.
ANSWER
Because the designers want to remind us of the invisible underpinnings that hold up our houses, buildings, bridges, and ourselves when we are on stilts. This excellent description of Struts reflect the role the Struts plays in developing web applications.
ANSWER
ction, ActionForm, ActionServlet, ActionMapping, ActionForward are basic classes of Structs.
ANSWER
The role played by Structs is controller in Model/View/Controller(MVC) style. The View is played by JSP and Model is played by JDBC or generic data source classes. The Struts controller is a set of programmable components that allow developers to define exactly how the application interacts with the user.
ANSWER
The Struts is not only thread-safe but thread-dependent(instantiates each Action once and allows other requests to be threaded through the original object. ActionForm beans minimize subclass code and shorten subclass hierarchies The Struts tag libraries provide general-purpose functionality The Struts components are reusable by the application The Struts localization strategies reduce the need for redundant JSPs The Struts is designed with an open architecture--subclass available The Struts is lightweight (5 core packages, 5 tag libraries) The Struts is open source and well documented (code to be examined easily) The Struts is model neutral
ANSWER
The class org.apache.struts.action.ActionServlet is the called the ActionServlet. In the the Jakarta Struts Framework this class plays the role of controller. All the requests to the server goes through the controller. Controller is responsible for handling all the requests.
ANSWER
The configuration files hibernate.cfg.xml (or hibernate.properties) and mapping files *.hbm.xml are used by the Configuration class to create (i.e. configure and bootstrap hibernate) the SessionFactory, which in turn creates the Session instances. Session instances are the primary interface for the persistence service. " hibernate.cfg.xml (alternatively can use hibernate.properties): These two files are used to configure the hibernate sevice (connection driver class, connection URL, connection username, connection password, dialect etc). If both files are present in the classpath then hibernate.cfg.xml file overrides the settings found in the hibernate.properties file. " Mapping files (*.hbm.xml): These files are used to map persistent objects to a relational database. It is the best practice to store each object in an individual mapping file (i.e mapping file per class) because storing large number of persistent classes into one mapping file can be difficult to manage and maintain. The naming convention is to use the same name as the persistent (POJO) class name. For example Account.class will have a mapping file named Account.hbm.xml. Alternatively hibernate annotations can be used as part of your persistent class code instead of the *.hbm.xml files.
ANSWER
SessionFactory is Hibernate
ANSWER
Session is a light weight and a non-threadsafe object (No, you cannot share it between threads) that represents a single unit-of-work with the database. Sessions are opened by a SessionFactory and then are closed when all work is complete. Session is the primary interface for the persistence service. A session obtains a database connection lazily (i.e. only when required). To avoid creating too many sessions ThreadLocal class can be used as shown below to get the current session no matter how many times you make call to the currentSession() method.
ANSWER
Detached objects can be passed across layers all the way up to the presentation layer without having to use any DTOs (Data Transfer Objects). You can later on re-attach the detached objects to another session.
ANSWER
Both the session.get(..) and session.load() methods create a persistent object by loading the required object from the database. But if there was not such object in the database then the method session.load(..) throws an exception whereas session.get(&) returns null.
ANSWER
Both of these methods and saveOrUpdate() method are intended for reattaching a detached object. The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object. It is the best practice to use either session.update(..) or session.saveOrUpdate(). Use session.lock() only if you are absolutely sure that the detached object is in sync with your detached object or if it does not matter because you will be overwriting all the columns that would have changed later on within the same transaction.
ANSWER
You can use the session.merge() method call.
ANSWER
The configuration files hibernate.cfg.xml (or hibernate.properties) and mapping files *.hbm.xml are used by the Configuration class to create (i.e. configure and bootstrap hibernate) the SessionFactory, which in turn creates the Session instances. Session instances are the primary interface for the persistence service.
ANSWER
Persistent objects and collections are short lived single threaded objects, which store the persistent state. These objects synchronize their state with the database depending on your flush strategy (i.e. auto-flush where as soon as setXXX() method is called or an item is removed from a Set, List etc or define your own synchronization points with session.flush(), transaction.commit() calls). If you remove an item from a persistent collection like a Set, it will be removed from the database either immediately or when flush() or commit() is called depending on your flush strategy. They are Plain Old Java Objects (POJOs) and are currently associated with a session. As soon as the associated session is closed, persistent objects become detached objects and are free to use directly as data transfer objects in any application layers like business layer, presentation layer etc. Detached objects and collections are instances of persistent objects that were associated with a session but currently not associated with a session. These objects can be freely used as Data Transfer Objects without having any impact on your database. Detached objects can be later on attached to another session by calling methods like session.update(), session.saveOrUpdate() etc. and become persistent objects. Transient objects and collections are instances of persistent objects that were never associated with a session. These objects can be freely used as Data Transfer Objects without having any impact on your database. Transient objects become persistent objects when associated to a session by calling methods like session.save( ), session.persist( ) etc.
ANSWER
Ans: This question is first step towards spring and mostly interviewer starts from this question. As the name implies inversion of control means now we have inverted the control of creating the object from our own using new operator to container or framework Now it’s the responsibility of container to create object as required. We maintain one xml file where we configure our components, services, all the classes and their property. We just need to mention which service is needed by which component and container will create the object for us. This concept is known as dependency injection because all object dependency (resources) is injected into it by framework. Example:
ANSWER
BeanFactory is factory Pattern which is based on IoC.it is used to make a clear separation between application configuration and dependency from actual code. XmlBeanFactory is one of the implementation of bean Factory which we have used in our project. Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDr8XD7q
ANSWER
This one is very popular spring interview question and often asks in entry level interview. ApplicationContext is preferred way of using spring because of functionality provided by it and interviewer wanted to check whether you are familiar with it or not. Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDrYGnQT
ANSWER
spring have seven core modules 1. The Core container module 2. Application context module 3. AOP module (Aspect Oriented Programming) 4. JDBC abstraction and DAO module 5. O/R mapping integration module (Object/Relational) 6. Web module 7. MVC framework module Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDri0A8n
ANSWER
This is another popular spring interview questions and an important concept to understand. Basically a bean has scopes which defines their existence on the application Singleton: means single bean definition to a single object instance per Spring IoC container. Prototype: means a single bean definition to any number of object instances. Whatever beans we defined in spring framework are singleton beans. There is an attribute in bean tag named ‘singleton’ if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans. Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDrsnnFq
ANSWER
This spring interview questions is little difficult as compared to previous questions just because transaction management is a complex concept and not every developer familiar with it. Transaction management is critical in any applications that will interact with the database. The application has to ensure that the data is consistent and the integrity of the data is maintained. Two type of transaction management is supported by spring 1. Programmatic transaction mgt. 2. Declarative transaction mgt. Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDs2no8k
ANSWER
The core construct of AOP is the aspect, which encapsulates behaviors affecting multiple classes into reusable modules. AOP is a programming technique that allows developer to modularize crosscutting concerns, that cuts across the typical divisions of responsibility, such as logging and transaction management. Spring AOP, aspects are implemented using regular classes or regular classes annotated with the @Aspect annotation Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDsB1SOo
ANSWER
It’s an implementation of aspect; advice is inserted into an application at join points. Different types of advice include “around,” “before” and “after” advice Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDsJwFnP
ANSWER
This is not really a spring interview questions I would say an AOP one. AOP is another popular programming concept which complements OOPS. Join point is an opportunity within code for which we can apply an aspect. In Spring AOP, a join point always represents a method execution. Pointcut: a predicate that matches join points. A point cut is something that defines at what joinpoints an advice should be applied These spring interview Questions are not very difficult in nature and focused on spring fundamentals rather than focusing on advanced feature of session management, sprint security, authentication etc. we will cover of those question on some other interview article. I would also suggest that share some spring questions asked to you guys during interview and than I can put together those with there answers for quick reference of everybody. Read more: http://javarevisited.blogspot.com/2011/09/spring-interview-questions-answers-j2ee.html#ixzz1tDsUn693
ANSWER
You can deliver a bean as either its bytecode (compiled Java code) or as a serialized object (after the bean instance is serialized to a file (*.ser)). The difference is that when you load the bean by its bytecode the bean loader normally create an instance from it by calling the default constructor (no arguments constructor). If you have a serialized instance the loader creates the instance like it was when it was serialized and therefore its internal state is recreated (except transient fields). Therefore you can provide already customized beans for a particular purpose instead of letting the bean user do this. So you can provide beans for the different Swing look and feels which vary in its background color, borders, fonts, etc. Then the bean user can select for the one he prefers instead of trying settings the bean properties.
ANSWER
A servlet bean is a serializable servlet that follows the JavaBeans component architecture, basically offering getter/setter methods. As long as you subclass GenericServlet/HttpServlet, you are automatically Serializable. If your web server supports them, when you install the servlet in the web server, you can configure it through a property sheet-like interface.
ANSWER
A JavaBean component can be used anywhere, either like an AWT component on the client or with a JSP page on the server. There is nothing that requires it to be one or the other. In fact, the same bean can be used for both.
ANSWER
You can think of the manifest file as the Jar-file meta-data, describing the contents of the files inside the Jar. Each file in the .jar file can have an entry in the manifest file. This entry can include information stating that the entry is a JavaBean component and/or whether or not the entry has been signed. For JavaBeans, the manifest file will be read when you import the JAR into your Bean builder tool. The tool will search the manifest file for those entries that have been flagged as JavaBeans, and more likely then not, add them to the tools component palette.
ANSWER
A Java Bean is a reusable software component that can be visually manipulated in builder tools.
ANSWER