Unit - I With A Neat Diagram Explain MVC Architecture
Unit - I With A Neat Diagram Explain MVC Architecture
MVC stands for Model-View-Controller architecture. It divides the functionality of displaying and maintaining of the data
to minimize the degree of coupling between components. It is used to separate core business model functionality from the
presentation and control logic that uses this functionality. It allows multiple views to share the same enterprise data model
and makes supporting multiple clients easier to implement, test, and maintain.
MVC is often used by applications that need the ability to maintain multiple views of the same data. Multiple views and
controllers can interface with the same model and even new types of views and controllers can interface with a model
without forcing a change in the model design.
Model-View-Controller architecture is used mainly for interactive web-applications. This model minimizes the coupling
between business logic and data presentation to web user. This model divides the application into three layers:
View:
A View accesses data from the model and specifies how that data should be presented. View is responsible for
presentation aspect of application according to the model data and also responsible to forward query response to the
controller. When the model changes, it is the views responsibility to maintain consistency in its presentation.
The view forwards user gestures to the controller. In a stand-alone GUI client, these user gestures could be button clicks
or menu selections. In a Web application, they appear as GET and POST HTTP requests to the Web tier.
Based on the user gesture and the outcome of the model commands, the controller selects a view to be rendered as part of
the response to this user request. There is usually one controller for each set of related functionality.
Example: Human resources applications typically have a controller for managing employee interactions and a controller for
human resources personnel.
Controller:
A Controller defines application behavior. Controller can also be depends on the type of clients. . In a stand-alone GUI
client, controller interprets user gestures and maps them into actions to be perform by the model. User interactions in a
Web application appear as GET and POST HTTP requests. Controller accepts and intercepts user requests and controls
the business objects to fulfill these requests. Based on the user interactions and the outcome of the model actions, the
controller responds by selecting an appropriate view. An application has one controller for related functionality.
The J2EE platform uses a distributed multitiered architecture in which the application logic is divided into components
according to their functions. There are four tiers in j2ee architecture. These are as shown in the diagram below.
Enterprise
Client Tier Presentation Tier Business Logic Tier Information
System Tier
Pure HTML / Java
Applet /
JSP / Servlet EJB
Java Application
Client Tier
Client tier consists of programs that interact with the user. It prompts the user for input and then converts the users
response into requests that are forwarded to software on a component that processes the request and returns results to the
client program. J2EE clients can be classified as follows
Web client is a software(usually browser) that accesses resources located on the web tier.
Ejb client can access one or more enterprise javabeans that are located on the EJB tier rather than resources on the
web tier.
EIS clients are the interface between users and resources located on the EIS tier.
Multi-tier clients can access components located on tiers other than the tier where the multi-tier client resides.
Web Tier
Web tier accepts requests from other software that was sent using POST, GET, and PUT operations, which are part of
HTTP transmissions. The two major components of web tier are Servlets and Java Server Pages. A servlet is a java class
that resides on the web tier and is called by a request from a browser client that operates on the client tier. A servlet is
associated with a URL that is mapped by the servlet container. It typically generates an HTML output stream that is
returned to the web server. The web server in turn transmits the data to the client. JSP is different than a servlet depending
on the container that is used. JSP uses custom tags to access the bean.
Enterprise java bean is a class that contains business logic and callable from a servlet or Jsp. EJB tier contains the
enterprise java beans server that stores and manages enterprise java beans. This tier automatically handles concurrency
issues that assure multiple clients have simultaneous access to the same object and also manages instances of components.
EJB server and EJB container is responsible for low level system services that are essential for implementing business
logic.
This tier provides flexibility to developers of J2EE applications since it include variety of resources and support
connectivity to resources. It defines all the elements that are needed to communicate between J2EE application and non-
J2EE software.
The J2EE architecture provides many advantages and benefits. Among other benefits, the J2EE platform offers
developers a simplified development environment that scales easily and can be integrated with existing systems and
applications. It also gives developers the flexibility to choose servers, tools, or other components that best fit their needs,
and to customize the security model for their needs. Vendors and customers alike benefit from the J2EE platform, as
follows:
Enterprise system vendors can implement compliant products that are also customizable.
Corporate information technologists benefit from the advantages of portable component technologythey can focus on
supporting business process requirements rather than handling distributed infrastructure integration problems.
With a neat diagram explain the life cycle of stateful session bean
Unit -II
An ActionForm represents an HTML form that the user interacts with over one or more pages. You will provide
properties to hold the state of the form with getters and setters to access them. Whereas,
using DynaActionForm there is no need of providing properties to hold the state. Instead these properties and
their type are declared in the struts-config.xml
The DynaActionForm bloats up the Struts config file with the xml based definition. This gets annoying as the
Struts Config file grow larger.
The DynaActionForm is not strongly typed as the ActionForm. This means there is no compile time checking for
the form fields. Detecting them at runtime is painful and makes you go through redeployment.
ActionForm can be cleanly organized in packages as against the flat organization in the Struts Config file.
ActionForm were designed to act as a Firewall between HTTP and the Action classes, i.e. isolate and
encapsulate the HTTP request parameters from direct use in Actions. With DynaActionForm, the property
access is no different than using request.getParameter( .. ).
DynaActionForm construction at runtime requires a lot of Java Reflection (Introspection) machinery that can be
avoided.
Unit - III
Unit - IV
Unit - V
Programs
Create guest book using JSTL tags. The program must list all the previously submitted comments and allow the
user to insert name and comment to the database
Create a web page that uses JSTL to read employee details(empno, ename dept, design) from an XML document
and display it in a tabular format.
Create a web page that uses JSTL to read Product details [ ProdID, ProdName, UnitPrice] from an XML document
and display it in a tabular format
Create a simple login application in JSF that accepts username and password. If username is equal to password
then the login is successful otherwise login fails.
Create a simple console application that uses hibernate to store the employee details(empno, ename,
department, designation) in a derby database.
Creat a simple console application that uses hibernate to store student details (regno, name, course, semester) in
a derby database.
Demonstrate the one-to-many mapping for a bill and item using hibernate. Entity bill contains many items
Demonstrate the one-to-many mapping between a Student Entity and Test Entity using Hibernate. The criteria
is a student can take many tests.
Demonstrate the use of before advice AOP for a typical Student class. Create a method studying() in student
class and set an advice that prints the time before this method is called.