You are on page 1of 40

Lecture 1

An introduction to
web programming
with Java
CGI is obsolete – see https://www.w3.org/CGI/ for information
Popular Website using Java Web
Application Back End - 2016
1.Google Programming languages

for Back End: Java, Perl,
• Programming C++
languages for Back
End: C, C++, Go, Java,
1.Twitter
• Programming languages
Python.
for Back End: Java, C++,
2.Youtube Ruby on Rails, Scala
• Programming languages
for Back End: Python,
2.Ebay
• Programming languages
C/C++, Go, Java
for Back End: JavaScript,
3.Facebook Java
• Programming languages
for Back End: PHP, Hack,
3.Linkedin
• Programming languages
Java, C++, Erlang, Python,
for Back End:
D, Xhp
JavaScript,Java, Scala
4.Amazon
 Source: https://codingsec.net/2016/06/programming-languages-used-top-websites/
Most In Demand Language by Job
Openings in 2017 – Indeed.com
 As the world’s largest job search
engine, Indeed represents a good
measurement of the most in-
demand programming jobs. 
Objective
Objective (cont..)
The first page of a shopping cart application
The second page of a shopping cart application
Components of a Web Application
The Component of Web Application
How a web server processes static web pages
How static web pages work
How a web server processes dynamic web pages
How dynamic web pages work
The components of a Java web application
Components needed for Java web application
A JSP that displays three parameters entered by
the user
An introduction to Java Server Pages
The code for the JSP
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Murach's Java Servlets and JSP</title>
</head>
<body>
<%
// get parameters from the request
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String emailAddress = request.getParameter("emailAddress");
%>
<h1>Thanks for joining our email list</h1>
The code for the JSP (cont..)
<p>Here is the information that you entered:</p>
<table cellspacing="5" cellpadding="5" border="1">
<tr>
<td align="right">First name:</td>
<td><%= firstName %></td>
</tr>
<tr>
<td align="right">Last name:</td>
<td><%= lastName %></td>
</tr>
<tr>
<td align="right">Email address:</td>
<td><%= emailAddress %></td>
</tr>
</table>
The code for the JSP (cont..)
<p>To enter another email address, click on the Back <br>
button in your browser or the Return button shown <br>
below.</p>

<form action="join_email_list.html" method="get">


<input type="submit" value="Return">
</form>
</body>
</html>
Code for a servlet that works the same as the JSP
package email;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayEmailListServlet extends HttpServlet{
protected void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{
// get parameters from the request
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String emailAddress = request.getParameter("emailAddress");

// return response to browser


response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
out.println("<!doctype html public \“
+ "-//W3C//DTD HTML 4.0 Transitional//EN\">\n""
+ "<html>\n"
Code for a servlet that works the same as the JSP
(cont..)
+ "<head>\n"
+ " <title>Murach's Java Servlets and JSP</title>\n"
+ "</head>\n"
+ "<body>\n"
+ "<h1>Thanks for joining our email list</h1>\n"
+ "<p>Here is the information that you entered:</p>\n"
+ " <table cellspacing=\"5\" cellpadding=\"5\" "
+ "border=\"1\">\n"
+ " <tr><td align=\"right\">First name:</td>\n"
+ " <td>" + firstName + "</td>\n"
+ " </tr>\n"
+ " <tr><td align=\"right\">Last name:</td>\n"
+ " <td>" + lastName + "</td>\n"
+ " </tr>\n"
+ " <tr><td align=\"right\">Email address:</td>\n"
+ " <td>" + emailAddress + "</td>\n"
+ " </tr>\n"
Code for a servlet that works the same as the JSP
(cont..)
+ " </table>\n"
+ "<p>To enter another email address, click on the Back <br>\n"
+ "button in your browser or the Return button shown <br>\n"
+ "below.</p>\n"
+ "<form action=\"join_email_list.html\" >\n"
+ " <input type=\"submit\" value=\"Return\">\n"
+ "</form>\n"
+ "</body>\n"
+ "</html>\n");
out.close();
}
}
Three environments for servlet an JSP development
The architecture for a typical Java web application
The architecture for a typical Java web application
(cont..)
The NetBeans IDE
Popular IDEs for Java web development
 NetBeans
 Eclipse
 Jbuilder
 IntelliJ IDEA

An Integrated Development Environment (IDE)


is a tool that provides all of the functionality
that you need for developing web applications.
An ISP that provides web hosting that supports
servlets and JSPs
The FileZilla Program
Software
 NetBeans 8.2 with Java http://www.oracle.com/technetwork/
java/javase/downloads/jdk-netbeans
Development Kit 8u151 & -jsp-142931.html
Apache Tomcat 8.0.27
 Apache Tomcat 8.5.24 https://tomcat.apache.org/download-
80.cgi#8.5.24

 Java EE Development Kit 8 http://www.oracle.com/technetwork/j


ava/javaee/downloads/java-ee-sdk-d
ownloads-3908423.html
 MySQL Server
https://dev.mysql.com/downloads/wi
ndows/installer/5.7.html
 Eclipse IDE for Java EE http://www.eclipse.org/downloads/pa
Developers ckages/eclipse-ide-java-ee-developer
s/oxygen2
Download Java EE

You might also like