Monday, December 3, 2018

JAVA PERSISTENCE API FOR JAVA SE 7 DESKTOP APPLICATION IN NETABEANS 7

Please watch the video to follow exact instructions to create java persistence api for java se 7.




Use full links

Download JAVA JDK
https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html

download netbeans
https://netbeans.org/downloads/


Derby Client --- optional if not found in java from program files
https://db.apache.org/derby/releases/release-10.14.2.0.cgi

SERVLETS

Java servlet processes or stores a Java class inJava EE that conforms to the Java Servlet API, a standard for implementing Java classes that respond to requests. Servlets could in principle communicate over any client–server protocol, but they are most often used with the HTTP.


Execution of Servlets : 
Execution of Servlets involves the six basic steps:
1.    The clients send the request to the web server.
2.    The web server receives the request.
3.    The web server passes the request to the corresponding servlet.
4.    The servlet processes the request and generate the response in the form of output.
5.    The servlet send the response back to the web server.
6.    The web server sends the response back to the client and the client browser displays it on the screen.
                                                                                                                                                                                                           
JAVA SERVLET PAGES
JavaServer Pages (JSP) is a technology that helps software developers create dynamically generated web pages based on HTML, XML, or other document types. Released in 1999 by Sun Microsystems,[1] JSP is similar to PHP and ASP, but it uses the Java programming language.
To deploy and run JavaServer Pages, a compatible web server with a servlet container, such as Apache Tomcat or Jetty, is required.

JAVA SERVER FACES
JavaServer Faces (JSF) is a MVC web framework that simplifies the construction of User Interfaces (UI) for server-based applications using reusable UI components in a page. JSF provides a facility to connect UI widgets with data sources and to server-side event handlers. The JSF specification defines a set of standard UI components and provides an Application Programming Interface (API) for developing components. JSF enables the reuse and extension of the existing standard UI components.

FACELETS
In computingFacelets is an open-source Web template system under the Apache license and the default view handler technology (aka view declaration language) for JavaServer Faces (JSF). The language requires valid input XML documents to work. Facelets supports all of the JSF UI components and focuses completely on building the JSF component tree, reflecting the view for a JSF application.


MODEL VIEW CONTROLLER

In MVC  model ,MVC is a presentation layer pattern. The entire Model-View-Controller exists in presentation layer.
·         Model is object holding data (usually just VOs) which are represented by View 
·         Controller is what gets the request (and may  populate the model) and calls the service layer. Then gets another (or  same) model and sends it back to View.
·         View is what displays model, and provides  components to capture user input. (It is usually UI components).

THREE TIER APPLICATION



·Presentation Tier- The presentation tier is the front end layer in the 3-tier system and consists of the user interface. This user interface is often a graphical one accessible through a web browser or web-based application and which displays content and information useful to an end user. This tier is often built on web technologies such as HTML5, JavaScript, CSS, or through other popular web development frameworks, and communicates with others layers through API calls.

·Application Tier- The application tier contains the functional business logic which drives an application’s core capabilities. It’s often written in Java, .NET, C#, Python, C++, etc.

·Data Tier- The data tier comprises of the database/data storage system and data access layer. Examples of such systems are MySQL, Oracle, PostgreSQL, Microsoft SQL Server, MongoDB, etc. Data is accessed by the application layer via API calls.

Creating hello world application

To run this tutorial, as a minimum you will be required to have installed the following prerequisite software:
  1. Sun JDK 6.0+ (J2SE 1.6)
  2. Eclipse IDE for Java EE Developers, which is platform specific
  3. Apache Geronimo Eclipse Plugin 2.1.x
  4. Apache Geronimo Server 2.1.x

Details on installing eclipse are provided in the Development environment section. 
  • Creating a dynamic Web project using Eclipse
  • Adding a JSP to the project
  • Making hellp.jsp the welcome file
  • Run and deploy

Creating a dynamic Web project using Eclipse

  1. Launch Eclipse and Switch to Java EE perspective.






  2. Right click under the project explorer and select Dynamic Web Project as shown in the figure



  3. Name the project as HelloWorld.



  4. Keep default values for all the fields and select Finish.



Adding a JSP to the project

  1. Right-click on the project HelloWorld and create a new JSP as shown in the figure.



  2. Give the name as hello.jsp and select Next. Select Finish on the next screen 



  3. Modify the code of hello.jsp as follows:
    hello.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Hello World</title>
    </head>
    <body>
    Hello World!!
    </body>
    </html>

Making hellp.jsp the welcome file

  1. Click WebContent -> WEB-INF and open web.xml.
  2. Add hello.jsp as a welcome file under the <welcome-file-list> tag:
    web.xml
    <?xml version="1.0" encoding="UTF-8"?>
             xmlns="http://java.sun.com/xml/ns/javaee"
             xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
       <display-name>HellowWorld</display-name>
       <welcome-file-list>
        <welcome-file>hello.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
        <welcome-file>index.htm</welcome-file>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>default.html</welcome-file>
        <welcome-file>default.htm</welcome-file>
        <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    </web-app>

Run and deploy

  1. Deploy the application on the server.



  2. launch the application using http://localhost:8080/HelloWorld/hello.jsp



  3. This will display HelloWorld!! on the browser window.