What is MVC in struts 2 ?

 MVC in struts 2 :

In struts Model, View and Controller(MVC) is a design pattern, which is used to develop web application in java.
Model : It is responsible for retrieving data from the database and saving the data into the database. It also responsible to implements all business logic. When a data entered by the user through view are checked in the model before saving into the database. Data access, data validation and the data saving logic are part of model component.

View: It is represents the user view of the application which is responsible for taking the input from the user, dispatching the request to the controller and then receiving response from the controller and displaying the result back to the user. html, jsp, custom tag libraries, resources files are the part of view component.

Controller: It is intermediary between Model and View components. It is also responsible for receiving the request from client through view. Once request is received from client it executes the appropriate business logic from the Model and then produce the result to the user using the View component. ActionServlet, Action, ActionSupport and struts.xml are the part of Controller.

You can better understand through below diagram :

mvc diagram

 

Advertisements

Difference between include Directive and include Action in jsp

Difference between include Directive and include action :

The include Directive and include Action both are used to include content into a jsp page. But some differences between them are as follows :

  • The include directive tag include the content in the generated servlet page during the translation phase of jsp life cycle. It used to include file such as html, xml, jsp or .txt file into a jsp page statically. While include action tag include the response generated by executing the given jsp or servlet page during request processing phase.
  • The include directive tag does not allow us to use the expression for giving the url path, to including the resource in jsp page. While include action tag accepts expression.

Include tag in jsp

Include tag  :

Include action tag allows us to include a static or dynamic pages like html or jsp, specified by url during request processing. If page are static then its content is included in the calling jsp page. If requested page are dynamic then its output will be included on calling jsp. When requested page is dynamic then we can use <jsp:param> tag to pass name/value parameter in calling jsp.

Syntax :


<jsp:include attribute>

<!-- one or more <jsp:param> tag   -->

</jsp:include>

<jsp:include> action tag has “page” and “flush” attribute, which used to accept values for the specified jsp page.

page : It takes a relative url, which locate requested page. Here we can include relative url directly or in an expression within page attribute.

Note : Relative url can’t contain protocol, port, or domain name and starts with “/” character that specifying the url is taken relative to context path.

Example :

<jsp:include page=”/myhtml.html”/></pre>
<jsp:include page=”<%=mypath%>”/>
<pre>

flush : It indicate the buffer needs to flushed or not before including the page and takes true or false values. If value is true, the buffer is flushed and its false by default.

Action tags in jsp

Action tags :

In JSP action tags include in jsp 1.1 version and some more tags added in jsp1.2 and 2.0 version.

Action tags allow us to include some basic actions like inserting some other page resources, forwarding request to another pages, creating and locating javabean instances, setting and getting bean properties, in jsp page. When jsp container encounters an action tag during converting a jsp to servlet, it generates corresponds java code to the required predefined task.

Example :


<jsp:include page=”myjsp.jsp” flush=”true” />

There are some useful action tags as below mentions :

  • <jsp:include>
  • <jsp:forward>
  • <jsp:param>
  • <jsp:useBean>
  • <jsp:setProperty>
  • <jsp:getProperty>
  • <jsp:plugin>
  • <jsp:fallback>
  • <jsp:element>
  • <jsp:text>
  • <jsp:params>
  • <jsp:attribute>
  • <jsp:body>

Advantages of Hibernate Framework

Advantages of  Hibernate Framework :

  • Hibernate has capability to generate primary keys automatically while storing the records into database.
  • Hibernate provide automatic table creation facility.
  • Hibernate framework supports Inheritance, Associations, Collections.
  • Hibernate has annotations facilities.
  • In hibernate if you save the subclass class object, then its super class object will also be stored into the database, that is hibernate supporting inheritance.
  • Hibernate provide caching technique through this, an application can increase its performance automatically.
  • Hibernate supports relationships such as One-To-Many,One-To-One, Many-To-Many-to-Many, Many-To-One
    it is also supports collections like list, set, map, bag.
  • In hibernate you only have Un-checked(Runtime) exceptions, so don’t need to write try-catch block, or throws. Because in hibernate has translator which converts checked to Un-checked.
  • Hibernate has its own query language, that is hibernate query language(HQL) which is database independent. So that if you will change the database, then your application will works properly due to HQL is database independent.
  • Pagination can use in hibernate is very simple.
  • Hibernate provides Dialect classes, so you don’t need to write sql specific queries in hibernate, instead use the methods provided by API.

What is Hibernate Framework

Hibernate Framework :

Hibernate framework is an ORM(Object Relational Mapping) tools which is used to map java class with database table name and class variable with database table’s column. It is open source(free of cost) anybody can download its jar from hibernate.org/orm/downloads/ and use.

Hibernate framework provide database specific Dialect which used to switch different database without code change in application. Through this a programmer don’t need to write database specific query.

 

Hadoop deployment method

There are many methods used to deploy Hadoop,  few are as follows :

Standalone :

In this method, there are no daemons running, everythings runs as in a single JVM. This method is suitable for running MapReduce program during development and it is easy test, debug.

Pseudo-distributed :

The Hadoop daemon process runs on a local machine simulating a cluster on a small scale.

Fully distributed :

Here, Hadoop runs on a cluster of machines which provides production environment.