Download Tuesday January 30

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
MC365
Application Servers,
Servlets, and
Java Server Pages (JSP’s):
Tomcat
Today We Will Cover:
• What is an application server?
• How do servlets and jsp’s work with an
application server?
• Introduce the Tomcat application server.
What is an application server?
• It is easier to answer this question by looking at
the history of dynamic web pages and the factors
that led to the development of the application
server.
• Years ago dynamic web pages were generated
using a technology called CGI (Common Gateway
Interface).
– This was usually a program written in C, Perl or some
other similar language.
– The web server was configured to recognize certain
http requests and execute that program.
– This worked well for a while.
Disadvantages of CGI
• As the web became more and more popular, the load
placed on these web servers and CGI programs increased.
• One of the major inefficiencies of CGI programming is
that every time a request is made for that program, a new
instance is kicked off by the web server.
• For popular websites, this can quickly use up all of the
resources on that server causing delays or even crashes.
• In the late 1990s, the popularity of the Internet was
increasing at a remarkable rate. At the same time a new
language was also become more and more popular…Java.
Benefits of Java Servlets
• The creators of Java came up with an interesting
solution to the CGI problem – Java servlets.
• Servlets are a type of Java program similar to
applications and applets.
– We will go over servlets in more detail in the next class.
• They are Java’s answer to server-side
programming.
Benefits of Java Servlets
• So, what makes servlets better than CGI?
– Servlets are multi-threaded
• First and foremost, servlets take advantage of Java’s concept of
threads. This is a major advantage.
• When a request is made to the web server calling for it to
execute the java program, the Java program can just kick off a
new thread instead of instantiating a new instance of the
program. This saves a tremendous amount of server resources.
– Portable
• As with all other java programs, servlets can run on multiple
platforms. Remember Sun’s promise of write once, run
anywhere philosophy.
– Industry standard
• Java is pretty well established as the language of choice for
server-side programming for the web.
So, again what is an application server?
• Ok, getting back to the original question.
– Unlike CGI programs, Java servlets can not be called
directly by the web server. They need a container as
defined by the J2EE standard.
– This container is called an application server.
– The application server, or app server as it is often
called, works in concert with the web server. Actually,
most of today’s app servers have built-in web servers.
– This is the way it works:
How the Process Works
•
•
•
•
The user submits an http request via a web
browser (like Netscape or IE).
The http request is received by the web server,
which has been configured to send certain
requests to the application server.
The application server receives these special
requests. It knows which servlet to execute
based on the http request (the app server has its
own configuration).
The servlet is executed, does its thing, and
generates a response to the user in html format.
How do JSP’s fit in?
– The Java servlet can produce the HTML response directly
or it can call a Java Server Page (JSP) to generate the
HTML.
– Why would you want to use a JSP?
– The main reason for using JSP’s is to separate the presentation
from the business logic.
– Servlets are generally responsible for performing the business
logic.
– JSP’s are generally responsible for presentation.
– If you generate the HTML directly in the servlet, any changes to
design need a programmer.
– If you use a JSP, many design changes can be done by the UI team
directly.
– We will cover JSP’s in a lot more detail in a week.
The Tomcat Application Server
– Application servers are basically programs (just as web
servers are).
– Different companies have developed a variety of
application servers. Here are the industry leaders:
– WebLogic
– IBM’s WebSphere
– Tomcat
– WebLogic and WebSphere are marketed for large-scale
enterprises.
– They are industrial strength packages but they are very expensive.
– Together they own most of the app server market share.
The Tomcat Application Server
– Tomcat is an app server produced by the Jakarta project.
– It is free and open source.
– It is a very good app server and is a favorite among many smaller
organizations that don’t need many of the bells and whistles of the
other two and/or can’t afford them.
– It is a great tool to learn on. Once you become familiar with one
app server, it is much easier to learn the others.
– Tomcat is much easier to manage than many of the other
application servers.
So how do you set up Tomcat?
– Tomcat can run on many different platforms. In
this class we will go over how to install Tomcat on
the Windows operating system.
– You are free to install it on another operating system if
you want. Once installed, management of the app
server is relatively the same regardless of the OS.
– However, because most students here run Windows,
that is the OS we will use in class.
Installing Tomcat?
– Go to
http://mirror.telentente.com/pub/apache/dist/jakarta/tomcat-4/binaries/
Click on the tomcat-4.1.18.exe download link and save it to your
system.
Execute the executable.
Verify that your installation is
running successfully
–
–
–
–
Open a web browser.
Go to http://localhost:8080/
Click on the Servlet Examples link.
Execute the Hello World example.
– You should see Hello World!