Download presentation
Presentation is loading. Please wait.
Published byAlexander Harvey Modified over 9 years ago
1
Application Servers: Tomcat
2
What is an application server? Servlets are Java’s answer to server-side programming. Servlets are a special type of Java program. – Like applets and applications. Servlets can not run on their own. – That is, you don’t just execute a servlet from a command prompt or in a browser. – Servlets are looking for special objects (request and response objects). – Because of this, servlets need to be run in a container that will provide these request and response objects. – This container is called an application server.
3
What is an application server? Application servers usually work in concert with a web server. – In fact, today’s app servers usually have web servers built in. Here is how the process works: – The user submits a request from a browser (e.g. Netscape, IE) – The web server receives the request from the browser and recognizes it as a special request for a servlet. This is done by configuring the web server to recognize certain url’s as servlet requests. – The web server passes the request to the application server. – The application server processes the request and returns a response to the web server. – The web server passes the response to the browser.
4
Tomcat There are dozens of application servers on the market. The market leaders are WebLogic, WebSphere and Tomcat – probably in that order. – WebLogic and WebSphere are usually chosen for very large enterprises. Industrial strength with many bells and whistles like clustering, transaction mgmt, EJB support, load balancing, fail-over support, etc. Also VERY expensive. – Tomcat is the server of choice for more of the small-to- medium size organizations. It is a very solid application server that has most of the functionality of the more expensive servers. It is also much more easy to manage and work with. It is the perfect tool to use for an introduction to app servers. Best of all, it is fee.
5
Installing Tomcat Tomcat needs Windows NT, 2000 Server, or XP. – It will not work on Windows 98. – If you are using a version of Unix, you will need to download the appropriate tar file. To install Tomcat go to: CD drive or place where you have tomcat software Save the jakarta-tomcat-5.0.5 to your hard drive and double-click to begin installation. Follow the directions on the screen.
6
Verifying Tomcat Installation Note: You should set the cache in your browsers to zero when testing servlets. – Forces the browser to make a new call to the server every time. To test your installation type in your browser: http://localhost:8080/ http://localhost:8080/ Go to servlet examples.
7
Starting and Stopping Tomcat There really is no need to start and stop the server. – Installs as an NT Service. – Tomcat has dynamic servlet loading. If you do want to start and stop Tomcat manually, you need to kill the NT process if it is running. Then to start and stop the server, go to Programs/Apache Tomcat 5.0/Start Tomcat (or Stop Tomcat).
8
Tomcat Configuration 1)Set PATH to \install directory\common\lib\servlet- api.jar 2)write servlet program and compile it and place servlet class file in install directory\webapps\servlet- examples\ WEB-INF\classes directory Or Create a New project directory in webapps and create one more directory with name WEB-INF and create web.xml file and classes directory in WEB-INF
9
Tomcat Configuration Modify web.xml which you find in WEB-INF deirectory add entry for your new servlet Following is the sample servlet entry for the servlet helloworld. HelloWorldExample HelloWorldExample /servlet/HelloWorldExample Restart tomcat server Test it using the link http://localhost:8080/servlets-examples/servlet/HelloWorldExample Or http://localhost:8080/new project directory/servlet/HelloWorldExample
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.