Professional Documents
Culture Documents
Architecture
أبيسلّوم
ّ .قم.إعداد م
1
• The expectation for instant gratification was ratcheted up a notch with the
growth of the Internet.
• Java programming language is used to build software for this new multi-tier
architecture.
2
• A group of technologies that provide one or more services to
its clients.
3
4
Java 2 Platform, Enterprise Edition (J2EE)
Multi-Tier Architecture
• J2EE is a four-tier architecture
5
.Cont
• There are two types of components that work on the Web Tier.
These are servlets and JavaServer Pages (JSP).
6
7
Servlets
8
GlassFish
• GlassFish is a very popular server
• GassFish is:
o Efficient
o Secure
o Up to date with current standards
o Open source
o Free
9
Ports
• A port is a connection between a server and a client
o Ports are identified by positive integers
o A port is a software notion, not a hardware notion, so there may be
very many of them
• A service is associated with a specific port
o Typical port numbers:
• 21—FTP, File Transfer Protocol
• 22—SSH, Secure Shell
• 25—SMTP, Simple Mail Transfer Protocol
• 53—DNS, Domain Name Service
• 80—HTTP, Hypertext Transfer Protocol These are the ports
• 8080—HTTP (used for testing HTTP) Glassfish of most interest to us
• 7648, 7649—CU-SeeMe
• 27960—Quake III
10
Writing a Servlet
• Create a servletclass
o extend HttpServlet
• Implement the doGet() or doPost() method
o Both methods accept two parameters
HttpServletRequest
HttpServletResponse
o Obtain parameters from HttpServletRequest Interface using
getParameter(String name)
o Obtain the writer from the response object
o Process input data and generate output (in html form) and
write to the writer
o Close the writer
11
Response from server to client
• Everything sent via the Web has a “MIME type”
12
Getting the parameters
• Using reguest object in doGet method
• Reguest. getParameterNames()
Returns an Enumeration of the parameter names
• Reguest. getParameter(String name)
Returns the value of the parameter name as a String
• Reguest. getParameterValues(name)
Returns an array of values of the parameter name
13
14
Servletclass (at the server side)
15
Index.html
16
JDBC
17
JDBC Architecture
• JDBC API: This provides the application-to-JDBC Manager
connection.
18
19
MySQL
o speed
o flexibility
o reliability.
21
JDBC Step 1: Load the Driver
try {
Class.forName ("com.mysql.jdbc.Driver");
Class.forName ("oracle.jdbc.driver.OracleDriver");
}
catch (ClassNotFoundException cnfe) {
System.out.println("Error loading driver: " + cnfe);
}
22
JDBC Step 2: Define the Connection URL
Examples:
23
JDBC Step 3: Establish the Connection
• Connection connection = DriverManager.getConnection
(mySqlUrl, username,password);
24
JDBC Step 5: Execute a Query
25
JDBC Step 6: Process the Result
• resultSet.next()
o Goes to the next row. Returns false if no next row.
• resultSet.getString("columnName")
o Returns value of column with designated name in current
row, as a String. Also getInt, getDouble, etc.
• connection.close();
26
.Start your MySQL server
• MySQL server is running on port 3306 (whereas the GlassFish
is running on port 8080).
o cd \”path to mysql”\bin
o mysqld --console
27
The software used
Version Software
5.1.45 mysql-connector-java
28
Download mysql
• Download MySQL ZIP ARCHIVE from
https://dev.mysql.com/downloads/mysql/:
A. Choose "General Available (GA) Releases" tab.
29
Download mysql connectors
30
31