CIS 3052 [Part 2] 2014/2015

Size: px
Start display at page:

Download "CIS 3052 [Part 2] 2014/2015"

Transcription

1 Java EE Course Notes Course Notes & Examples for CIS 3052 [Part 2] 2014/2015 These notes belong to Name: Mobile: Prepared and compiled by Matthew Xuereb

2 Contact details Name: Matthew Xuereb Office Telephone: (+356) URL: Office: Room 318 Engineering Building University of Malta Msida Copyright These notes were prepared and compiled by Matthew Xuereb B.Sc. I.T. (Hons.), M.Sc The contents of this course and its modules and related materials, including handouts are Copyright 2014/2015 Matthew Xuereb. Preface Various books and websites were used for the compilation of these notes. The readers of these notes are encouraged to use other books and the web to find more Java examples. Matthew Xuereb 2014/2015 Page 2 of 40

3 Table of contents The Java EE... 4 Java Database Connectivity (JDBC)... 5 Java Servlets and Java Server Pages (JSP)... 8 Servlets and JSP Tutorial Servlets, JSP and JDBC Case Study Java Persistence API (JPA) Java Server Faces (JSF) Matthew Xuereb 2014/2015 Page 3 of 40

4 OVERVIEW The Java EE Developers today increasingly recognize the need for distributed, transactional, and portable applications that leverage the speed, security, and reliability of server-side technology. Enterprise applications provide the business logic for an enterprise. They are centrally managed and often interact with other enterprise software. In the world of information technology, enterprise applications must be designed, built, and produced for less money, with greater speed, and with fewer resources. The aim of the Java EE platform is to provide developers with a powerful set of APIs while shortening development time, reducing application complexity, and improving application performance [Taken from Matthew Xuereb 2014/2015 Page 4 of 40

5 CIS 3052[Part 2] JDBC Java Database Connectivity (JDBC) JDBC stands for Java Database Connectivity. This is an API for the Java programming language that defines how a client may access a (relational oriented) database. It provides methods for querying and updating data in a database. This API enables Java programs to execute SQL statements and to interact with any SQL-compliant database. Since nearly all relational database management systems (DBMSs) support SQL, and because Java itself runs on most platforms, JDBC makes it possible to write a single database application that can run on different platforms and interact with different DBMSs. The MySQL Database Engine MySQL is a relational database management system that runs as a server providing multiuser access to a number of databases. The MySQL development project has made its source code available under the terms of the GNU General Public License, as well as under a variety of proprietary agreements. MySQL was owned and sponsored by a single for-profit firm, the Swedish company MySQL AB, now owned by Sun Microsystems, a subsidiary of Oracle Corporation. Free-software projects that require a full-featured database management system often use MySQL. MySQL is also used in many high-profile, large-scale World Wide Web products including Wikipedia, Google and Facebook. The MySQL community server can be downloaded at no charge from A special interfacing file called the JDBC Driver for MySQL is required to interface the MySQL database engine to JDBC. This file can be downloaded from Connecting to a database using Java via JDBC There are three main steps required to use a database from a Java program. These are: 1. Connect to the data source (database) 2. Send queries and update statements to the database 3. Retrieve and process the results received from the database in answer to your query In this section, examples of how to manipulate databases with JDBC are given. A students table is used as a dummy for the code illustrated below. The database management system that is used for this example is the MySQL Server. This table is illustrated below: Id Name Surname Tel Address Class Subject1 Subject2 Subject3 1 Matthew Xuereb Mosta 3B Italian Computer Studies Chemistry 2 Joe Borg San Gwann 4B French Biology Chemistry 3 Paul Camilleri Luqa 5B Latin Computer Business Studies Studies As the table is stored in a MySQL database server, the JDBC Driver for MySQL is required and should be included in the Libraries section via the NetBeans IDE as explained below: Matthew Xuereb 2014/2015 Page 5 of 40

6 CIS 3052[Part 2] JDBC 1. Right click on the Libraries icon under the Projects section an click on the Add JAR/Folder option as shown in the screen shoot below: 2. Select the MySQL Connector driver and click on open as shown in the screen shoot below: Example The following example illustrates how a database can be queried: public class DBDemo { /** The JDBC driver name */ static final String JDBC_DRIVER = "com.mysql.jdbc.driver"; /** The database URL */ static final String DATABASE_URL = "jdbc:mysql://localhost/school"; /** The database username */ static final String DATABASE_USERNAME = "root"; /** The database password */ static final String DATABASE_PASSWORD = "letmein"; // The main method public static void main(string[] args) { // Create a reference to a connection Connection connection = null; Matthew Xuereb 2014/2015 Page 6 of 40

7 CIS 3052[Part 2] JDBC // Create a reference to a statement Statement statement = null; try{ //Load the database driver class Class.forName(JDBC_DRIVER); // Establish the connecion to the database connection = DriverManager.getConnection(DATABASE_URL, DATABASE_USERNAME, DATABASE_PASSWORD); // Create a statement for querying database statement = connection.createstatement(); // Query the database ResultSet resultset = statement.executequery( "SELECT name,surname,class FROM students"); // Process the query results ResultSetMetaData metadata = resultset.getmetadata(); int numofcolumns = metadata.getcolumncount(); // Display the column names for(int i = 1;i <= numofcolumns;i++){ System.out.printf("%-8s\t",metaData.getColumnName(i)); System.out.println(); // Display the data while(resultset.next()){ for(int i = 1;i <= numofcolumns;i++){ System.out.printf("%-8s\t",resultSet.getObject(i)); System.out.println(); // Close the connections resultset.close(); statement.close(); connection.close(); catch(exception e){ e.printstacktrace();; In order to add (update) records to a database, a statement as shown in the example below should be used: String updatestatement = "(name,surname,tel,address,class,subject1,subject2,subject3) " + "VALUES ('Joseph','Xuereb',' ','Mosta','3B','Italian', + 'Computer Studies','Chemistry')"); statement.executeupdate(updatestatement); Matthew Xuereb 2014/2015 Page 7 of 40

8 SERVLETS & JSP Java Servlets and Java Server Pages (JSP) In order to develop web pages with JSP and servlets using NetBeans, a Web Application project should be initiated as explained below: 1. Create a new project and select Web Application and click on Next as shown in the screen shots below: 2. Enter the Project Name and click on Next as shown in the screen shot below: Matthew Xuereb 2014/2015 Page 8 of 40

9 SERVLETS & JSP 3. Select the Web Server (In our case GlassFish Server 3) and click on Finish. 4. The NetBeans environment should then look as shown in the screen shot below, with the Projects section (as illustrated on the left hand side of the screen shot) illustrating a web project rather than a Java application. Matthew Xuereb 2014/2015 Page 9 of 40

10 SERVLETS & JSP 5. In order to execute the web application, right click on the source code window and click on Run File as shown in the screen shot below: Note that this time, when the application is executed, first the web server is initiated and the application is executed on the default web browser. Java Servlet Overview The Java Servlet technology provides Web developers with a simple, consistent mechanism for extending the functionality of a Web server and for accessing existing business systems. A servlet can almost be thought of as an applet that runs on the server side however without a face. Java servlets make many Web applications possible. Matthew Xuereb 2014/2015 Page 10 of 40

11 SERVLETS & JSP Servlets are the Java platform technology of choice for extending and enhancing Web servers. Servlets provide a component-based, platform-independent method for building Web-based applications, without the performance limitations of CGI programs. And unlike proprietary server extension mechanisms (such as the Netscape Server API or Apache modules), servlets are server and platform independent. This leaves you free to select a "best of breed" strategy for your servers, platforms, and tools. Servlets have access to the entire family of Java APIs, including the JDBC API to access enterprise databases. Servlets can also access a library of HTTP-specific calls and receive all the benefits of the mature Java language, including portability, performance, reusability, and crash protection. Today servlets are a popular choice for building interactive Web applications. Third-party servlet containers are available for Apache Web Server, Microsoft IIS, and others. Servlet containers are usually a component of Web and application servers, such as BEA WebLogic Application Server, IBM WebSphere, Sun Java System Web Server, Sun Java System Application Server, and others. JSP Overview Java Server Pages (JSP) technology enables Web developers and designers to rapidly develop and easily maintain, information-rich, dynamic Web pages that leverage existing business systems. As part of the Java technology family, JSP technology enables rapid development of Web-based applications that are platform independent. JSP technology separates the user interface from content generation, enabling designers to change the overall page layout without altering the underlying dynamic content. A JSP page can consists of four main elements. These are: 1. Template text. Generally consists of HTML code which consist scripting tags to be interpreted by the browser rather than server. 2. Scripting Elements. Specifically Java code which will be embedded in servlet. 3. JSP Directives. Enable the programmer to control the overall structure of the generated servlet. 4. JSP Actions. Enable the programmer to make use of existing components and to control behavior of the JSP engine. Apart from this, JSP provides access to a number of predefined variables such as request, response and session. JSP Scriptlets There are three main scripting elements in JSP Expressions, Scriptlets and Declarations. These are explained below. Matthew Xuereb 2014/2015 Page 11 of 40

12 SERVLETS & JSP Expressions An expression is a term which can be evaluated and which has a return of some type. Java expressions can be inserted into a JSP such that this expression is evaluated at the moment when the page is being serviced to a client. The syntax for a JSP expression is: <%=..expression.. %> Example: Note the use of predefined variable request used to get the host name of client in the JSP expression. A JSP page provides access to a number of variables which are usually available in a servlet. These are request, response and session. Matthew Xuereb 2014/2015 Page 12 of 40

13 SERVLETS & JSP Scriptlets A scriptlet enable the programmer to insert arbitrary code, possibly more complex than expressions into the service method. The syntax for a JSP scriptlets is: <%..java code.. %> Example: Matthew Xuereb 2014/2015 Page 13 of 40

14 SERVLETS & JSP Declarations A JSP declaration enables the programmer to define methods or fields outside the service method of the servlet. The syntax for a JSP declaration is: <%!..java code.. %> Example: Matthew Xuereb 2014/2015 Page 14 of 40

15 SERVLETS & JSP TUTORIAL Servlets and JSP Tutorial Java Servlets Example 1 (Plain Servlet) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import = "Servlet1", urlpatterns = {"/Servlet1") public class Servlet1 extends HttpServlet protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head> <title>my first servlet</title> </head>"); out.println("<body>"); out.println("<h1>welcome to Servlets!</h1>"); out.println("</body>"); out.println("</html>"); out.close(); Matthew Xuereb 2014/2015 Page 15 of 40

16 SERVLETS & JSP TUTORIAL HTML PAGE CODE <html> <head> <title>an HTML page to invoke the welcome Servlet</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <form action="servlet1" method="get"> <label> Click on the button to invoke the servlet</label> <input type="submit" value="click HERE"/> </form> </body> </html> Matthew Xuereb 2014/2015 Page 16 of 40

17 SERVLETS & JSP TUTORIAL Example 2 (Servlet with form data using GET) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import = "Servlet2", urlpatterns = {"/Servlet2") public class Servlet2 extends HttpServlet protected void doget(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head>"); out.println("<title>my second servlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>extracting data using get request</h1>"); // Get the data String name = request.getparameter("name"); String surname = request.getparameter("surname"); String age = request.getparameter("age"); out.println("hello " + name + " " + surname + "!<br/>"); try{ Matthew Xuereb 2014/2015 Page 17 of 40

18 SERVLETS & JSP TUTORIAL int ageint = Integer.parseInt(age); if(ageint < 18){ out.println("you cannot drive"); else{ out.println("you can drive"); catch(exception e){ // Do nothing out.println("</body>"); out.println("</html>"); out.close(); HTML PAGE CODE <html> <head> <title>an HTML page to invoke the Servlet using a get</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <h1>fill in the following form</h1> <form action="servlet2" method="get"> <label>name: </label> <input type="text" name="name"/> <br/> <br/> <label>surname: </label> <input type="text" name="surname"/> <br/><br/> <label>age: </label> <input type="text" name="age"/> <br/><br/> <input type="submit" value="submit"/> </form> Matthew Xuereb 2014/2015 Page 18 of 40

19 SERVLETS & JSP TUTORIAL </body> </html> Matthew Xuereb 2014/2015 Page 19 of 40

20 SERVLETS & JSP TUTORIAL Example 3 (Servlet with form data using POST) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet; import javax.servlet.http.httpservletrequest; import = "Servlet3", urlpatterns = {"/Servlet3") public class Servlet3 extends HttpServlet protected void dopost(httpservletrequest request, HttpServletResponse response) throws ServletException, IOException { response.setcontenttype("text/html"); PrintWriter out = response.getwriter(); out.println("<html>"); out.println("<head>"); out.println("<title>my second servlet</title>"); out.println("</head>"); out.println("<body>"); out.println("<h1>extracting data using post request</h1>"); // Get the data String name = request.getparameter("name"); String surname = request.getparameter("surname"); String age = request.getparameter("age"); out.println("hello " + name + " " + surname + "!<br/>"); try{ int ageint = Integer.parseInt(age); Matthew Xuereb 2014/2015 Page 20 of 40

21 SERVLETS & JSP TUTORIAL if(ageint < 18){ out.println("you cannot drive"); else{ out.println("you can drive"); catch(exception e){ // Do nothing out.println("</body>"); out.println("</html>"); out.close(); HTML PAGE CODE <html> <head> <title>an HTML page to invoke the Servlet using a post</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> </head> <body> <h1>fill in the following form</h1> <form action="servlet3" method="post"> <label>name: </label> <input type="text" name="name"/> <br/> <br/> <label>surname: </label> <input type="text" name="surname"/> <br/><br/> <label>age: </label> <input type="text" name="age"/> <br/><br/> <input type="submit" value="submit"/> </form> </body> </html> Matthew Xuereb 2014/2015 Page 21 of 40

22 SERVLETS & JSP TUTORIAL Matthew Xuereb 2014/2015 Page 22 of 40

23 SERVLETS & JSP TUTORIAL Java Server Pages (JSP) Example 1 JSP Code <%@page import="java.text.simpledateformat"%> <%@page import="java.util.date" %> <html> <head> <title>jsp Page showing the current date and time</title> </head> <body> <h1>date and time</h1> Current time: <%= new Date() %> <br/><br/> Date only: <% Date now = new Date(); String fulldateandtime = now.tostring(); SimpleDateFormat dateformat = new SimpleDateFormat("dd/MM/yyyy"); out.println(dateformat.format(now)); %> </body> </html> Matthew Xuereb 2014/2015 Page 23 of 40

24 SERVLETS & JSP TUTORIAL Generated HTML code <html> <head> <title>jsp Page showing the current date and time</title> </head> <body> <h1>date and time</h1> Current time: Fri Aug 17 11:40:31 CEST 2012 <br/><br/> Date only: 17/08/2012 </body> </html> Matthew Xuereb 2014/2015 Page 24 of 40

25 SERVLETS & JSP TUTORIAL Example 2 HTML Code <html> <head> <title>an HTML page to invoke a JSP page</title> </head> <body> <h1>times table</h1> <form action="timestable.jsp" method="get"> <label>enter a number to display it's times table: </label> <input type="text" name="num"/> <br/><br/> <input type="submit" value="submit"/> </form> </body> </html> Matthew Xuereb 2014/2015 Page 25 of 40

26 SERVLETS & JSP TUTORIAL JSP Code <html> <head> <title>jsp Page showing the times table</title> </head> <body> <%! int num = 1; %> <% %> String snum = request.getparameter("num"); try{ num = Integer.parseInt(sNum); catch(exception e){ // Do nothing <h1>the <%=num%> times table</h1> <% %> </body> </html> for(int i = 1;i <= 10;i++){ out.println("<br/>" + num + " x " + i + " = " + num*i); Matthew Xuereb 2014/2015 Page 26 of 40

27 SERVLETS & JSP TUTORIAL Generated HTML code <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>jsp Page showing the times table</title> </head> <body> <h1>the 5 times table</h1> <br/>5 x 1 = 5 <br/>5 x 2 = 10 <br/>5 x 3 = 15 <br/>5 x 4 = 20 <br/>5 x 5 = 25 <br/>5 x 6 = 30 <br/>5 x 7 = 35 <br/>5 x 8 = 40 <br/>5 x 9 = 45 <br/>5 x 10 = 50 </body> </html> Matthew Xuereb 2014/2015 Page 27 of 40

28 SERVLETS, JSP & JDBC CASE STUDY Servlets, JSP and JDBC Case Study You have been hired to write a [very basic] web application that is going to be used by travel agents to book flights. A central database named flightsdb is used. This database contains two tables, one named users that holds the Travel Agents credentials and another table called flights that holds the flight details including the remaining seats on a particular flight. Samples of these two tables are displayed below. Table: users username password SkyTours qqqwww FlyAway gggxxx itours kkkooo Table: flights id flight_num flight_date seats_left 1 KM102 20/01/ KM100 20/01/ KM102 21/01/ EY /01/ FR /01/ Develop this system by answering the following questions: 1. Create on your local host computer the fligthsdb database and fill it with some sample data as shown above. 2. Write an HTML page LoginPage.html that allows the user to enter the username and password so that the user can login to the system. 3. Write a servlet LoginServlet that accepts the username and password and check whether these are valid or not. If these are valid, the servlet should automatically redirect to the BookFlights.jsp page. 4. Write the JSP page BookFlights.jsp. This web page should allow the user to enter the flight number, flight date and amount of seats to book. When the user clicks on the Book Flights button, the JSP page should redirect to the servlet CommitBookingServlet. 5. Write a servlet CommitBookingServlet that will perform the actual flights booking by subtracting the number of seats left from the flights table. Note that you should include all the necessary data validation and a session should be kept to make sure that only logged in users can book a flight. Matthew Xuereb 2014/2015 Page 28 of 40

29 JPA Java Persistence API (JPA) An entity class is a conventional Java class Plan Old Java Object (POJO) that is used to be mapped to a particular database table. An entity can either be mapped to an existing table or else it can be used to actually generate a new SQL table in a database. Creating an entity class from a database table In this tutorial the flightsdb database that was created for the Servets/JSP tutorial is going to be used. This database is implemented using MySQL therefore it is important that the MySQL JDBC Connector library is included in the project. 1. Create a new entity class by selecting the option Entity Classes from Database as shown in the screen shot below: 2. A dialog box as shown below is displayed on the screen. You have to either select a stored connection (if you have already created other entities for the same project) or else select New Database Connection and follow the wizard to create a new database connection. Matthew Xuereb 2014/2015 Page 29 of 40

30 JPA 3. It is very important that when a new database connection is created, the appropriate database is selected as shown in the screen shot below: 4. When the database connection is established, a dialog box as shown below is displayed on the screen. Select the tables from the database that you want to map to an entity class and click on the Next button. Matthew Xuereb 2014/2015 Page 30 of 40

31 JPA 5. Select or type in a package where to store the entity classes and click on finish. 6. When you click on finish notice that an entity class is created together with a persistence.xml file in a META-INF sub-directory directory under the source package directory as shown in the screen shot below. This file will be explained later in this tutorial. The entity class When an entity class is created, apart from the usual Java code, the class is also populated with special annotations. These annotations are used to provide information about the mapping between the entity POJO and the SQL table. When an entity is mapped from an existing table using an IDE such as NetBeans or eclipse there is no need to add any other special annotations. The following is the code (excluding the package declaration and the imports) that was generated in the above example for the @NamedQuery(name = "Flights.findAll", query = "SELECT f FROM Flights = "Flights.findById", query = "SELECT f FROM Flights f WHERE f.id = = "Flights.findByFlightNum", query = "SELECT f FROM Flights f WHERE f.flightnum = = "Flights.findByFlightDate", query = "SELECT f FROM Flights f WHERE f.flightdate = = "Flights.findBySeatsLeft", query = "SELECT f FROM Flights f WHERE f.seatsleft = :seatsleft")) public class Flights implements Serializable { Matthew Xuereb 2014/2015 Page 31 of 40

32 JPA private static final long serialversionuid = = = "id") private Integer = = "flight_num") private String = = private Date = "seats_left") private Integer seatsleft; public Flights() { public Flights(Integer id) { this.id = id; public Flights(Integer id, String flightnum, Date flightdate) { this.id = id; this.flightnum = flightnum; this.flightdate = flightdate; public Integer getid() { return id; public void setid(integer id) { this.id = id; public String getflightnum() { return flightnum; public void setflightnum(string flightnum) { this.flightnum = flightnum; public Date getflightdate() { return flightdate; public void setflightdate(date flightdate) { this.flightdate = flightdate; public Integer getseatsleft() { return seatsleft; public void setseatsleft(integer seatsleft) { this.seatsleft = seatsleft; Matthew Xuereb 2014/2015 Page 32 of 40

33 public int hashcode() { int hash = 0; hash += (id!= null? id.hashcode() : 0); return public boolean equals(object object) { if (!(object instanceof Flights)) { return false; Flights other = (Flights) object; if ((this.id == null && other.id!= null) (this.id!= null &&!this.id.equals(other.id))) { return false; return public String tostring() { return "entities.flights[ id=" + id + " ]"; The following is the SQL code that was used to create the flights database table on the MySQL server: create table flights( id int primary key not null auto_increment, flight_num varchar(8) not null, flight_date date not null, seats_left int ); The entity class is following the rules of encapsulation and therefore all attributes are set to be private and getters and setters are used to provide access to them. An empty and parameter less constructor is included and the entity class is also implementing the Serializable interface. Note that although every item in the table is mapped to a Java POJO, the Java naming convention is used in the Java entity. For this reason, fields such as flight_num where written as flightnum in the Java entity class. To indicate the mapping (as different naming convention is used) notice the use of the both with the name field for the table fields and table name respectively. Other tags such as used to indicate which are the primary fields and the method of auto filling them with values. There are a lot of annotations that can be used with JPA 2.0. For a full list of annotations and their respective explanation, consult with the official Oracle Java EE 6 tutorial Matthew Xuereb 2014/2015 Page 33 of 40

34 JPA Creating an entity class and automatically creating an SQL table in database With JPA it is also possible to first create an entity class and then it JPA will automatically create it respective SQL table in the database. 1. Create a new entity class by selecting the Entity Class option. 2. Type in the name of the entity and the appropriate primary key type as shown in the screen shot below. 3. The outline of the entity class is automatically generated. The attributes of this entity should now be coded including the relevant JPA annotations, getters, setter and constructors. The following source code illustrates and example of an entity (excluding the package declaration and the imports) that was created from scratch and it will be used to create a new SQL table in the database. Notice that only few annotations were used in this example: Matthew Xuereb 2014/2015 Page 34 of 40

35 JPA public class Passenger implements Serializable { private static final long serialversionuid = GenerationType.AUTO) private Long id; private String name; private String private String passportnum; public Passenger(){ // Empty parameter less constructor public Passenger(String name,string surname,string passportnum){ this.name = name; this.surname = surname; this.passportnum = passportnum; public Long getid() { return id; public void setid(long id) { this.id = id; public String getname() { return name; public void setname(string name) { this.name = name; public String getsurname() { return surname; public void setsurname(string surname) { this.surname = surname; public String getpassportnum() { return passportnum; public void setpassportnum(string passportnum) { this.passportnum = public int hashcode() { int hash = 0; hash += (id!= null? id.hashcode() : 0); return hash; Matthew Xuereb 2014/2015 Page 35 of 40

36 public boolean equals(object object) { if (!(object instanceof Passenger)) { return false; Passenger other = (Passenger) object; if ((this.id == null && other.id!= null) (this.id!= null &&!this.id.equals(other.id))) { return false; return public String tostring() { return "entities.passenger[ id=" + id + " ]"; The persistence.xml file The persistence.xml file is usually generated automatically by the IDE. It is a very important file that is used to configure the persistence unit. The following is a screen shot of this file when opened by the NetBeans IDE after the above two entities are created: The above screen shot represents a simple GUI that can be used to configure the persistence.xml file. This GUI is a mapping to an xml file (click on source to view the file) that is shown below: <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" xmlns=" xmlns:xsi=" xsi:schemalocation=" <persistence-unit name="jpa_demopu" transaction-type="resource_local"> <provider>org.eclipse.persistence.jpa.persistenceprovider</provider> <class>entities.flights</class> <class>entities.passenger</class> <properties> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/flightsdb"/> <property name="javax.persistence.jdbc.password" value="letmein"/> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/> Matthew Xuereb 2014/2015 Page 36 of 40

37 JPA <property name="javax.persistence.jdbc.user" value="root"/> <property name="eclipselink.ddl-generation" value="create-tables"/> </properties> </persistence-unit> </persistence> The tag persistence-unit name is used to define an identifier for this particular persistence application. The provider tag is used to indicate the persistence unit provider. In the above example the provider is the EclipseLink however other such as Hibernate can be used. The list of class tags lists the entity classes. The property tag includes a number of very important properties such as the database url, username, password and driver. The property <property name="eclipselink.ddl-generation" value="create-tables"/> is used to allow the persistence unit to create new SQL tables in the database from a given entity class. Using entity classes The following are some examples of how to use entity classes and JPA to work with databases. Adding a new record Passenger passenger = new Passenger("Matthew","Xuereb","123456"); EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("JPA_DemoPU"); EntityManager em = emfactory.createentitymanager(); em.gettransaction().begin(); em.persist(passenger); em.gettransaction().commit(); em.close(); Querying a table using the Java Persistence Query Language EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("JPA_DemoPU"); EntityManager em = emfactory.createentitymanager(); Query query = em.createquery("select f from Flights f where f.flightnum='km102'"); List<Flights> result = query.getresultlist(); //... em.close(); Querying a table using Named queries Named queries are queries that can be written using JPU annotations as shown in the Flights entity example above. Note that when an entity is generated automatically from a table, such named queries are also generated automatically. EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("JPA_DemoPU"); EntityManager em = emfactory.createentitymanager(); Query query = em.createnamedquery("flights.findbyflightnum"); query.setparameter("flightnum","km102"); List<Flights> result = query.getresultlist(); //... em.close(); Matthew Xuereb 2014/2015 Page 37 of 40

38 JPA Updating a table record EntityManagerFactory emfactory = Persistence.createEntityManagerFactory("JPA_DemoPU"); EntityManager em = emfactory.createentitymanager(); em.gettransaction().begin(); Passenger passenger = em.find(passenger.class,new Long(1)); passenger.setpassportnum("56789"); em.gettransaction().commit(); em.close(); Matthew Xuereb 2014/2015 Page 38 of 40

39 JSF Java Server Faces (JSF) Designed to be flexible, JavaServer Faces technology leverages existing, standard UI and web-tier concepts without limiting developers to a particular mark-up language, protocol, or client device. The UI component classes included with JavaServer Faces technology encapsulate the component functionality, not the client-specific presentation, thus enabling JavaServer Faces UI components to be rendered to various client devices. By combining the UI component functionality with custom renderers, which define rendering attributes for a specific UI component, developers can construct custom tags to a particular client device. As a convenience, JavaServer Faces technology provides a custom renderer and a JSP custom tag library for rendering to an HTML client, allowing developers of Java Platform, Enterprise Edition (Java EE) applications to use JavaServer Faces technology in their applications. Creating a JSF Web application 1. Create a new Java Web application. 2. Make sure to click on the Next button when creating a new web application until you are asked to select the frameworks that you would like to use. Select the Java Server Faces framework and click Finish. Matthew Xuereb 2014/2015 Page 39 of 40

40 JSF 3. A new project is created and a default index.xhtml file is also generated as shown in the screen shot below. Notice that when creating JSF pages, xhtml files are used. The reason for this is that a JSF file is basically an XML based HTML file that can be mapped to Java classes. Notice that even the html tags are written in an XML fashion via a JSF label that by default is set h to refer to html tags. The web.xml file The web.xml file is generated automatically by the IDE and is found under the WEB-INF directory. This is a very important file as it is used to configure the JSF framework. The web.xml file stores in it information such as session timeouts, the JSF framework and more. A very important filed in this file is the welcome-file field that is used to indicate which file should be loaded first when the JSF web application is loaded. By default it is set to load first the index.xhtml web page. Example The usual flight booking system will be implemented during the lecture and subsequently uploaded on the website. Matthew Xuereb 2014/2015 Page 40 of 40

CIS 3952 [Part 2] Java Servlets and JSP tutorial

CIS 3952 [Part 2] Java Servlets and JSP tutorial Java Servlets Example 1 (Plain Servlet) SERVLET CODE import java.io.ioexception; import java.io.printwriter; import javax.servlet.servletexception; import javax.servlet.annotation.webservlet; import javax.servlet.http.httpservlet;

More information

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks

CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS. To create a servlet program to display the students marks CREATE A SERVLET PROGRAM TO DISPLAY THE STUDENTS MARKS DATE: 30.9.11 Aim: To create a servlet program to display the students marks Hardware requirements: Intel Core 2 Quad 2GB RAM Software requirements:

More information

Servlets by Example. Joe Howse 7 June 2011

Servlets by Example. Joe Howse 7 June 2011 Servlets by Example Joe Howse 7 June 2011 What is a servlet? A servlet is a Java application that receives HTTP requests as input and generates HTTP responses as output. As the name implies, it runs on

More information

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session

Kamnoetvidya Science Academy. Object Oriented Programming using Java. Ferdin Joe John Joseph. Java Session Kamnoetvidya Science Academy Object Oriented Programming using Java Ferdin Joe John Joseph Java Session Create the files as required in the below code and try using sessions in java servlets web.xml

More information

Thu 10/26/2017. Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8

Thu 10/26/2017. Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8 Created RESTful Web Service, JavaDB, Java Persistence API, Glassfish server in NetBeans 8 1 tutorial at http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/restfulwebservices/restfulwebservices.htm

More information

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition

CMP 436/774. Introduction to Java Enterprise Edition. Java Enterprise Edition CMP 436/774 Introduction to Java Enterprise Edition Fall 2013 Department of Mathematics and Computer Science Lehman College, CUNY 1 Java Enterprise Edition Developers today increasingly recognize the need

More information

Session 9. Introduction to Servlets. Lecture Objectives

Session 9. Introduction to Servlets. Lecture Objectives Session 9 Introduction to Servlets Lecture Objectives Understand the foundations for client/server Web interactions Understand the servlet life cycle 2 10/11/2018 1 Reading & Reference Reading Use the

More information

To create a view for students, staffs and courses in your departments using servlet/jsp.

To create a view for students, staffs and courses in your departments using servlet/jsp. Aim To create a view for students, staffs and courses in your departments using servlet/jsp. Software Requirements: Java IDE Database Server JDK1.6 Netbean 6.9/Eclipse MySQL Tomcat/Glassfish Login Form

More information

Web based Applications, Tomcat and Servlets - Lab 3 -

Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta The Basic Web Server CMPUT 391 Database Management

More information

Université Antonine - Baabda

Université Antonine - Baabda Université Antonine - Baabda Faculté d ingénieurs en Informatique, Multimédia, Systèmes, Réseaux et Télécommunications Applications mobiles (Pocket PC, etc ) Project: Manipulate School Database Préparé

More information

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans

Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Demonstration of Servlet, JSP with Tomcat, JavaDB in NetBeans Installation pre-requisites: NetBeans 7.01 or above is installed; Tomcat 7.0.14.0 or above is installed properly with NetBeans; (see step 7

More information

Develop an Enterprise Java Bean for Banking Operations

Develop an Enterprise Java Bean for Banking Operations Develop an Enterprise Java Bean for Banking Operations Aim: Develop a Banking application using EJB3.0 Software and Resources: Software or Resource Version Required NetBeans IDE 6.7, Java version Java

More information

JavaServer Pages (JSP)

JavaServer Pages (JSP) JavaServer Pages (JSP) The Context The Presentation Layer of a Web App the graphical (web) user interface frequent design changes usually, dynamically generated HTML pages Should we use servlets? No difficult

More information

Session 8. Introduction to Servlets. Semester Project

Session 8. Introduction to Servlets. Semester Project Session 8 Introduction to Servlets 1 Semester Project Reverse engineer a version of the Oracle site You will be validating form fields with Ajax calls to a server You will use multiple formats for the

More information

Accessing EJB in Web applications

Accessing EJB in Web applications Accessing EJB in Web applications 1. 2. 3. 4. Developing Web applications Accessing JDBC in Web applications To run this tutorial, as a minimum you will be required to have installed the following prerequisite

More information

JPA - ENTITY MANAGERS

JPA - ENTITY MANAGERS JPA - ENTITY MANAGERS http://www.tutorialspoint.com/jpa/jpa_entity_managers.htm Copyright tutorialspoint.com This chapter takes you through simple example with JPA. Let us consider employee management

More information

Introduction to Java Enterprise Edition For Database Application Developer

Introduction to Java Enterprise Edition For Database Application Developer CMP 420/758 Introduction to Java Enterprise Edition For Database Application Developer Department of Mathematics and Computer Science Lehman College, the CUNY 1 Java Enterprise Edition Developers today

More information

Advanced Internet Technology Lab # 4 Servlets

Advanced Internet Technology Lab # 4 Servlets Faculty of Engineering Computer Engineering Department Islamic University of Gaza 2011 Advanced Internet Technology Lab # 4 Servlets Eng. Doaa Abu Jabal Advanced Internet Technology Lab # 4 Servlets Objective:

More information

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets

Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets ID2212 Network Programming with Java Lecture 10 Enterprise Java Technologies (Part 1 of 3) Component Architecture. Overview of Java EE. Java Servlets Leif Lindbäck, Vladimir Vlassov KTH/ICT/SCS HT 2015

More information

CE212 Web Application Programming Part 3

CE212 Web Application Programming Part 3 CE212 Web Application Programming Part 3 30/01/2018 CE212 Part 4 1 Servlets 1 A servlet is a Java program running in a server engine containing methods that respond to requests from browsers by generating

More information

Stateless -Session Bean

Stateless -Session Bean Stateless -Session Bean Prepared by: A.Saleem Raja MCA.,M.Phil.,(M.Tech) Lecturer/MCA Chettinad College of Engineering and Technology-Karur E-Mail: asaleemrajasec@gmail.com Creating an Enterprise Application

More information

JdbcResultSet.java. import java.sql.*;

JdbcResultSet.java. import java.sql.*; 1)Write a program to display the current contents of the tables in the database where table name is Registration and attributes are id,firstname,lastname,age. JdbcResultSet.java import java.sql.*; public

More information

WHAT IS EJB. Security. life cycle management.

WHAT IS EJB. Security. life cycle management. EJB WHAT IS EJB EJB is an acronym for enterprise java bean. It is a specification provided by Sun Microsystems to develop secured, robust and scalable distributed applications. To run EJB application,

More information

Introduction to JPA. Fabio Falcinelli

Introduction to JPA. Fabio Falcinelli Introduction to JPA Fabio Falcinelli Me, myself and I Several years experience in active enterprise development I love to design and develop web and standalone applications using Python Java C JavaScript

More information

Module 8 The Java Persistence API

Module 8 The Java Persistence API Module 8 The Java Persistence API Objectives Describe the role of the Java Persistence API (JPA) in a Java EE application Describe the basics of Object Relational Mapping Describe the elements and environment

More information

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres

sessionx Desarrollo de Aplicaciones en Red A few more words about CGI CGI Servlet & JSP José Rafael Rojano Cáceres sessionx Desarrollo de Aplicaciones en Red José Rafael Rojano Cáceres http://www.uv.mx/rrojano A few more words about Common Gateway Interface 1 2 CGI So originally CGI purpose was to let communicate a

More information

Java Persistence API (JPA) Entities

Java Persistence API (JPA) Entities Java Persistence API (JPA) Entities JPA Entities JPA Entity is simple (POJO) Java class satisfying requirements of JavaBeans specification Setters and getters must conform to strict form Every entity must

More information

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang

Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang Supplement IV.E: Tutorial for Tomcat 5.5.9 For Introduction to Java Programming By Y. Daniel Liang This supplement covers the following topics: Obtaining and Installing Tomcat Starting and Stopping Tomcat

More information

ServletConfig Interface

ServletConfig Interface ServletConfig Interface Author : Rajat Categories : Advance Java An object of ServletConfig is created by the web container for each servlet. This object can be used to get configuration information from

More information

JAVA SERVLET. Server-side Programming INTRODUCTION

JAVA SERVLET. Server-side Programming INTRODUCTION JAVA SERVLET Server-side Programming INTRODUCTION 1 AGENDA Introduction Java Servlet Web/Application Server Servlet Life Cycle Web Application Life Cycle Servlet API Writing Servlet Program Summary 2 INTRODUCTION

More information

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실

Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 데이타베이스시스템연구실 Database Systems Lab. 11. JSP I 충남대학교컴퓨터공학과 데이타베이스시스템연구실 Overview http://www.tutorialspoint.com/jsp/index.htm What is JavaServer Pages? JavaServer Pages (JSP) is a server-side programming

More information

Introduction. This course Software Architecture with Java will discuss the following topics:

Introduction. This course Software Architecture with Java will discuss the following topics: Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Session 13. Reading. A/SettingUpJPA.htm JPA Best Practices

Session 13. Reading.  A/SettingUpJPA.htm JPA Best Practices Session 13 DB Persistence (JPA) Reading Reading Java EE 7 Tutorial chapters 37-39 NetBeans/Derby Tutorial www.oracle.com/webfolder/technetwork/tutorials/obe/java/settingupjp A/SettingUpJPA.htm JPA Best

More information

Java TM. JavaServer Faces. Jaroslav Porubän 2008

Java TM. JavaServer Faces. Jaroslav Porubän 2008 JavaServer Faces Jaroslav Porubän 2008 Web Applications Presentation-oriented Generates interactive web pages containing various types of markup language (HTML, XML, and so on) and dynamic content in response

More information

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature

INTRODUCTION TO SERVLETS AND WEB CONTAINERS. Actions in Accord with All the Laws of Nature INTRODUCTION TO SERVLETS AND WEB CONTAINERS Actions in Accord with All the Laws of Nature Web server vs web container Most commercial web applications use Apache proven architecture and free license. Tomcat

More information

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans

Advanced Topics in Operating Systems. Manual for Lab Practices. Enterprise JavaBeans University of New York, Tirana M.Sc. Computer Science Advanced Topics in Operating Systems Manual for Lab Practices Enterprise JavaBeans PART III A Web Banking Application with EJB and MySQL Development

More information

TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités. 1 Préparation de l environnement Eclipse

TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités. 1 Préparation de l environnement Eclipse TP 6 des architectures logicielles Séance 6 : Architecture n-tiers avec du JPA avec plusieurs entités 1 Préparation de l environnement Eclipse 1. Environment Used JDK 7 (Java SE 7) JPA 2.0 Eclipse MySQL

More information

Developing Applications with Java EE 6 on WebLogic Server 12c

Developing Applications with Java EE 6 on WebLogic Server 12c Developing Applications with Java EE 6 on WebLogic Server 12c Duration: 5 Days What you will learn The Developing Applications with Java EE 6 on WebLogic Server 12c course teaches you the skills you need

More information

Topics in Enterprise Information Management

Topics in Enterprise Information Management Topics in Enterprise Information Management Dr. Ilan Kirsh JPA Basics Object Database and ORM Standards and Products ODMG 1.0, 2.0, 3.0 TopLink, CocoBase, Castor, Hibernate,... EJB 1.0, EJB 2.0: Entity

More information

Handout 31 Web Design & Development

Handout 31 Web Design & Development Lecture 31 Session Tracking We have discussed the importance of session tracking in the previous handout. Now, we ll discover the basic techniques used for session tracking. Cookies are one of these techniques

More information

Principles and Techniques of DBMS 6 JSP & Servlet

Principles and Techniques of DBMS 6 JSP & Servlet Principles and Techniques of DBMS 6 JSP & Servlet Haopeng Chen REliable, INtelligent and Scalable Systems Group (REINS) Shanghai Jiao Tong University Shanghai, China http://reins.se.sjtu.edu.cn/~chenhp

More information

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4

The Basic Web Server CGI. CGI: Illustration. Web based Applications, Tomcat and Servlets - Lab 3 - CMPUT 391 Database Management Systems 4 CMPUT 391 Database Management Systems The Basic Web based Applications, - - CMPUT 391 Database Management Systems Department of Computing Science University of Alberta CMPUT 391 Database Management Systems

More information

Unit-4: Servlet Sessions:

Unit-4: Servlet Sessions: 4.1 What Is Session Tracking? Unit-4: Servlet Sessions: Session tracking is the capability of a server to maintain the current state of a single client s sequential requests. Session simply means a particular

More information

SDN Community Contribution

SDN Community Contribution SDN Community Contribution (This is not an official SAP document.) Disclaimer & Liability Notice This document may discuss sample coding or other information that does not include SAP official interfaces

More information

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1

Java Enterprise Edition. Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Enterprise Edition Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 1 Java Beans Java EE Oct Dec 2016 EFREI/M1 Jacques André Augustin Page 2 Java Bean POJO class : private Attributes public

More information

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003

Introduction. Literature: Steelman & Murach, Murach s Java Servlets and JSP. Mike Murach & Associates Inc, 2003 Introduction This course Software Architecture with Java will discuss the following topics: Java servlets Java Server Pages (JSP s) Java Beans JDBC, connections to RDBMS and SQL XML and XML translations

More information

Session 20 Data Sharing Session 20 Data Sharing & Cookies

Session 20 Data Sharing Session 20 Data Sharing & Cookies Session 20 Data Sharing & Cookies 1 Reading Shared scopes Java EE 7 Tutorial Section 17.3 Reference http state management www.ietf.org/rfc/rfc2965.txt Cookies Reading & Reference en.wikipedia.org/wiki/http_cookie

More information

Lab session Google Application Engine - GAE. Navid Nikaein

Lab session Google Application Engine - GAE. Navid Nikaein Lab session Google Application Engine - GAE Navid Nikaein Available projects Project Company contact Mobile Financial Services Innovation TIC Vasco Mendès Bluetooth low energy Application on Smart Phone

More information

Tutorial: Using Java/JSP to Write a Web API

Tutorial: Using Java/JSP to Write a Web API Tutorial: Using Java/JSP to Write a Web API Contents 1. Overview... 1 2. Download and Install the Sample Code... 2 3. Study Code From the First JSP Page (where most of the code is in the JSP Page)... 3

More information

SSC - Web applications and development Introduction and Java Servlet (I)

SSC - Web applications and development Introduction and Java Servlet (I) SSC - Web applications and development Introduction and Java Servlet (I) Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics What will we learn

More information

Session 10. Form Dataset. Lecture Objectives

Session 10. Form Dataset. Lecture Objectives Session 10 Form Dataset Lecture Objectives Understand the relationship between HTML form elements and parameters that are passed to the servlet, particularly the form dataset 2 10/1/2018 1 Example Form

More information

An implementation of Tree Panel component in EXT JS 4.0

An implementation of Tree Panel component in EXT JS 4.0 An implementation of Tree Panel component in EXT JS 4.0 By Hamid M. Porasl This implementation contains an HTML file that t is used to invoke used EXT JS java script files and our implemented java Script

More information

Using JPA to Persist Application Data in SAP HANA

Using JPA to Persist Application Data in SAP HANA Using JPA to Persist Application Data in SAP HANA Applies to: HANA Database, JAVA, JPA, JPaaS, Netwaever neo, SAP Research Security and Trust Summary In this document we propose a detailed solution to

More information

Entity LifeCycle Callback Methods Srikanth Technologies Page : 1

Entity LifeCycle Callback Methods Srikanth Technologies Page : 1 Entity LifeCycle Callback Methods Srikanth Technologies Page : 1 Entity LifeCycle Callback methods A method may be designated as a lifecycle callback method to receive notification of entity lifecycle

More information

Shale and the Java Persistence Architecture. Craig McClanahan Gary Van Matre. ApacheCon US 2006 Austin, TX

Shale and the Java Persistence Architecture. Craig McClanahan Gary Van Matre. ApacheCon US 2006 Austin, TX Shale and the Java Persistence Architecture Craig McClanahan Gary Van Matre ApacheCon US 2006 Austin, TX 1 Agenda The Apache Shale Framework Java Persistence Architecture Design Patterns for Combining

More information

J2EE Web Development 13/1/ Application Servers. Application Servers. Agenda. In the beginning, there was darkness and cold.

J2EE Web Development 13/1/ Application Servers. Application Servers. Agenda. In the beginning, there was darkness and cold. 1. Application Servers J2EE Web Development In the beginning, there was darkness and cold. Then, mainframe terminals terminals Centralized, non-distributed Agenda Application servers What is J2EE? Main

More information

Developing container managed persistence with JPA

Developing container managed persistence with JPA Developing container managed persistence with JPA Previous Developing bean managed persistence with JPA Up Developing JPA applications Developing persistence for JSF applications with JPA Next The Java

More information

Introduction to Servlets. After which you will doget it

Introduction to Servlets. After which you will doget it Introduction to Servlets After which you will doget it Servlet technology A Java servlet is a Java program that extends the capabilities of a server. Although servlets can respond to any types of requests,

More information

J2ME With Database Connection Program

J2ME With Database Connection Program J2ME With Database Connection Program Midlet Code: /* * To change this template, choose Tools Templates * and open the template in the editor. package hello; import java.io.*; import java.util.*; import

More information

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD

WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD W HI TEPAPER www. p rogres s.com WHITE LABELING IN PROGRESS ROLLBASE PRIVATE CLOUD In this whitepaper, we describe how to white label Progress Rollbase private cloud with your brand name by following a

More information

Practice 2. SOAP & REST

Practice 2. SOAP & REST Enterprise System Integration Practice 2. SOAP & REST Prerequisites Practice 1. MySQL and JPA Introduction JAX-WS stands for Java API for XML Web Services. JAX-WS is a technology for building web services

More information

Complimentary material for the book Software Engineering in the Agile World

Complimentary material for the book Software Engineering in the Agile World Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-93-5300-898-7) published by Amazon, USA (ISBN: 978-1976901751) and Flushing Meadows Publishers, India (ISBN: 978-93-5300-898-7)

More information

Information systems modelling UML and service description languages

Information systems modelling UML and service description languages Internet Engineering Tomasz Babczyński, Zofia Kruczkiewicz Tomasz Kubik Information systems modelling UML and service description languages Laboratory 4 Design patterns used to build the Integration nad

More information

COURSE 9 DESIGN PATTERNS

COURSE 9 DESIGN PATTERNS COURSE 9 DESIGN PATTERNS CONTENT Applications split on levels J2EE Design Patterns APPLICATION SERVERS In the 90 s, systems should be client-server Today, enterprise applications use the multi-tier model

More information

Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json

Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json Servlet for Json or CSV (or XML) A servlet serving either Json or CSV (or XML) based on GET parameter - This version uses org.json A Servlet used as an API for data Let s say we want to write a Servlet

More information

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation

Welcome To PhillyJUG. 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation Welcome To PhillyJUG 6:30-7:00 pm - Network, eat, find a seat 7:00-7:15 pm - Brief announcements 7:15-8:30 pm - Tom Janofsky's presentation Web Development With The Struts API Tom Janofsky Outline Background

More information

Contents. 1. JSF overview. 2. JSF example

Contents. 1. JSF overview. 2. JSF example Introduction to JSF Contents 1. JSF overview 2. JSF example 2 1. JSF Overview What is JavaServer Faces technology? Architecture of a JSF application Benefits of JSF technology JSF versions and tools Additional

More information

Java4570: Session Tracking using Cookies *

Java4570: Session Tracking using Cookies * OpenStax-CNX module: m48571 1 Java4570: Session Tracking using Cookies * R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract

More information

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module

Java EE Application Assembly & Deployment Packaging Applications, Java EE modules. Model View Controller (MVC)2 Architecture & Packaging EJB Module Java Platform, Enterprise Edition 5 (Java EE 5) Core Java EE Java EE 5 Platform Overview Java EE Platform Distributed Multi tiered Applications Java EE Web & Business Components Java EE Containers services

More information

JPA The New Enterprise Persistence Standard

JPA The New Enterprise Persistence Standard JPA The New Enterprise Persistence Standard Mike Keith michael.keith@oracle.com http://otn.oracle.com/ejb3 About Me Co-spec Lead of EJB 3.0 (JSR 220) Java EE 5 (JSR 244) expert group member Co-author Pro

More information

Java SE7 Fundamentals

Java SE7 Fundamentals Java SE7 Fundamentals Introducing the Java Technology Relating Java with other languages Showing how to download, install, and configure the Java environment on a Windows system. Describing the various

More information

Chapter 2 How to structure a web application with the MVC pattern

Chapter 2 How to structure a web application with the MVC pattern Chapter 2 How to structure a web application with the MVC pattern Murach's Java Servlets/JSP (3rd Ed.), C2 2014, Mike Murach & Associates, Inc. Slide 1 Objectives Knowledge 1. Describe the Model 1 pattern.

More information

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC)

Session 8. JavaBeans. Reading & Reference. Reading. Reference. Session 8 Java Beans. 2/27/2013 Robert Kelly, Head First Chapter 3 (MVC) Session 8 JavaBeans 1 Reading Reading & Reference Head First Chapter 3 (MVC) Reference JavaBeans Tutorialdocs.oracle.com/javase/tutorial/javabeans/ 2 2/27/2013 1 Lecture Objectives Understand how the Model/View/Controller

More information

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

Java- EE Web Application Development with Enterprise JavaBeans and Web Services Java- EE Web Application Development with Enterprise JavaBeans and Web Services Duration:60 HOURS Price: INR 8000 SAVE NOW! INR 7000 until December 1, 2011 Students Will Learn How to write Session, Message-Driven

More information

AJP. CHAPTER 5: SERVLET -20 marks

AJP. CHAPTER 5: SERVLET -20 marks 1) Draw and explain the life cycle of servlet. (Explanation 3 Marks, Diagram -1 Marks) AJP CHAPTER 5: SERVLET -20 marks Ans : Three methods are central to the life cycle of a servlet. These are init( ),

More information

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes Java CORE JAVA Core Java Programing (Course Duration: 40 Hours) Introduction to Java What is Java? Why should we use Java? Java Platform Architecture Java Virtual Machine Java Runtime Environment A Simple

More information

Author - Ashfaque Ahmed

Author - Ashfaque Ahmed Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-1983801570) published by Create Space Independent Publishing Platform, USA Author - Ashfaque Ahmed Technical support

More information

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming

PSD1B Advance Java Programming Unit : I-V. PSD1B- Advance Java Programming PSD1B Advance Java Programming Unit : I-V PSD1B- Advance Java Programming 1 UNIT I - SYLLABUS Servlets Client Vs Server Types of Servlets Life Cycle of Servlets Architecture Session Tracking Cookies JDBC

More information

CS506 Web Design & Development Final Term Solved MCQs with Reference

CS506 Web Design & Development Final Term Solved MCQs with Reference with Reference I am student in MCS (Virtual University of Pakistan). All the MCQs are solved by me. I followed the Moaaz pattern in Writing and Layout this document. Because many students are familiar

More information

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX Duration: 5 Days US Price: $2795 UK Price: 1,995 *Prices are subject to VAT CA Price: CDN$3,275 *Prices are subject

More information

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M

INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M 1.B HTML FORM CREATION - 2 M INTERNET PROGRAMMING TEST-3 SCHEME OF EVALUATION 1.A 3 LIFE CYCLE METHODS - 3M EXPLANATION - 1.B HTML FORM CREATION - 2 M SERVLET CODE IN POST METHOD IMPORT STATEMENTS - CLASS NAME AND METHOD (POST) -

More information

Courses For Event Java Advanced Summer Training 2018

Courses For Event Java Advanced Summer Training 2018 Courses For Event Java Advanced Summer Training 2018 Java Fundamentals Oracle Java SE 8 Advanced Java Training Java Advanced Expert Edition Topics For Java Fundamentals Variables Data Types Operators Part

More information

Server-side Web Programming

Server-side Web Programming Server-side Web Programming Lecture 13: JDBC Database Programming JDBC Definition Java Database Connectivity (JDBC): set of classes that provide methods to Connect to a database through a database server

More information

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps.

This tutorial will teach you how to use Java Servlets to develop your web based applications in simple and easy steps. About the Tutorial Servlets provide a component-based, platform-independent method for building Webbased applications, without the performance limitations of CGI programs. Servlets have access to the entire

More information

SYLLABUS JAVA COURSE DETAILS. DURATION: 60 Hours. With Live Hands-on Sessions J P I N F O T E C H

SYLLABUS JAVA COURSE DETAILS. DURATION: 60 Hours. With Live Hands-on Sessions J P I N F O T E C H JAVA COURSE DETAILS DURATION: 60 Hours With Live Hands-on Sessions J P I N F O T E C H P U D U C H E R R Y O F F I C E : # 4 5, K a m a r a j S a l a i, T h a t t a n c h a v a d y, P u d u c h e r r y

More information

SECTION II: JAVA SERVLETS

SECTION II: JAVA SERVLETS Chapter 7 SECTION II: JAVA SERVLETS Working With Servlets Working with Servlets is an important step in the process of application development and delivery through the Internet. A Servlet as explained

More information

Improve and Expand JavaServer Faces Technology with JBoss Seam

Improve and Expand JavaServer Faces Technology with JBoss Seam Improve and Expand JavaServer Faces Technology with JBoss Seam Michael Yuan Kito D. Mann Product Manager, Red Hat Author, JSF in Action http://www.michaelyuan.com/seam/ Principal Consultant Virtua, Inc.

More information

Servlet and JSP Review

Servlet and JSP Review 2006 Marty Hall Servlet and JSP Review A Recap of the Basics 2 JSP, Servlet, Struts, JSF, AJAX, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com

More information

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading.

Session 24. Introduction to Java Server Faces (JSF) Robert Kelly, Reading. Session 24 Introduction to Java Server Faces (JSF) 1 Reading Reading IBM Article - www.ibm.com/developerworks/java/library/jjsf2fu1/index.html Reference Sun Tutorial (chapters 4-9) download.oracle.com/javaee/6/tutorial/doc/

More information

Oracle Fusion Middleware 11g: Build Applications with ADF I

Oracle Fusion Middleware 11g: Build Applications with ADF I Oracle University Contact Us: +966 1 1 2739 894 Oracle Fusion Middleware 11g: Build Applications with ADF I Duration: 5 Days What you will learn This course is aimed at developers who want to build Java

More information

Author - Ashfaque Ahmed

Author - Ashfaque Ahmed Complimentary material for the book Software Engineering in the Agile World (ISBN: 978-1983801570) published by Create Space Independent Publishing Platform, USA Author - Ashfaque Ahmed Technical support

More information

Contents at a Glance

Contents at a Glance Contents at a Glance 1 Java EE and Cloud Computing... 1 2 The Oracle Java Cloud.... 25 3 Build and Deploy with NetBeans.... 49 4 Servlets, Filters, and Listeners... 65 5 JavaServer Pages, JSTL, and Expression

More information

WWW Architecture I. Software Architecture VO/KU ( / ) Roman Kern. KTI, TU Graz

WWW Architecture I. Software Architecture VO/KU ( / ) Roman Kern. KTI, TU Graz WWW Architecture I Software Architecture VO/KU (707.023/707.024) Roman Kern KTI, TU Graz 2013-12-04 Roman Kern (KTI, TU Graz) WWW Architecture I 2013-12-04 1 / 81 Web Development Tutorial Java Web Development

More information

Advanced Java Programming

Advanced Java Programming Advanced Java Programming Length: 4 days Description: This course presents several advanced topics of the Java programming language, including Servlets, Object Serialization and Enterprise JavaBeans. In

More information

Page 1

Page 1 Java 1. Core java a. Core Java Programming Introduction of Java Introduction to Java; features of Java Comparison with C and C++ Download and install JDK/JRE (Environment variables set up) The JDK Directory

More information

How to Develop a Simple Crud Application Using Ejb3 and Web Dynpro

How to Develop a Simple Crud Application Using Ejb3 and Web Dynpro How to Develop a Simple Crud Application Using Ejb3 and Web Dynpro Applies to: SAP Web Dynpro Java 7.1 SR 5. For more information, visit the User Interface Technology homepage. Summary The objective of

More information

SSC - Web development Model-View-Controller for Java Servlet

SSC - Web development Model-View-Controller for Java Servlet SSC - Web development Model-View-Controller for Java Servlet Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics Java Server Pages (JSP) Model-View-Controller

More information

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics:

Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics: Entities are classes that need to be persisted, usually in a relational database. In this chapter we cover the following topics: EJB 3 entities Java persistence API Mapping an entity to a database table

More information

Scheme G Sample Question Paper Unit Test 2

Scheme G Sample Question Paper Unit Test 2 Scheme G Sample Question Paper Unit Test 2 Course Name: Computer Engineering Group Course Code: CO/CD/CM/CW/IF Semester: Sixth Subject Title: Advanced Java Programming Marks: 25 Marks 17625 ---------------------------------------------------------------------------------------------------------------------------

More information

Getting started with Winstone. Minimal servlet container

Getting started with Winstone. Minimal servlet container Getting started with Winstone Minimal servlet container What is Winstone? Winstone is a small servlet container, consisting of a single JAR file. You can run Winstone on your computer using Java, and get

More information