Presentation is loading. Please wait.

Presentation is loading. Please wait.

Deploying Web Applications to Tomcat Server Chun Guo

Similar presentations


Presentation on theme: "Deploying Web Applications to Tomcat Server Chun Guo"— Presentation transcript:

1 Deploying Web Applications to Tomcat Server Chun Guo chunguo@indiana.edu

2 Deployment vs. Development Development Create the web application Deployment Make the web application available to use (publically accessible through URL). Publish your application on the server!

3 IP address, URL and DNS IP address – An Internet Protocol address (IP address) is a numerical label assigned to each device (e.g., computer, printer) participating in a computer network that uses the Internet Protocol for communication. – IP addresses are represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots – e.g. IP address for ILS website is 129.79.36.75

4 IP address, URL and DNS URL and DNS – The Domain Name System (DNS) is a hierarchical distributed naming system that translates easily remembered domain names (URL) to the numerical IP addresses. – It serves as the phone book for the Internet by translating human-friendly computer hostnames into IP addresses.

5 Look up IP address Check the IP address for a given domain – ping “domain name”

6 Check your own IP Address Windows – ipconfig Mac – ifconfig

7 The Large Picture

8 Outline Tomcat Basics Tomcat Administration Deploy web applications to Tomcat server – WAR file – Deployment folder

9 Outline Tomcat Basics Tomcat Administration Deploy web applications to Tomcat server – WAR file – Deployment folder

10 Server Hardware Software Database Server Web Server

11 http://news.netcraft.com/archives/2013/07/02/july-2013-web-server-survey.html

12 Tomcat Basics What is Tomcat? Web container – Manage Java Servlets HTTP Web server – Deliver web pages on the request to clients. – Receive content from clients. – Create HTML documents dynamically ("on-the- fly")

13 Install Tomcat Windows – Installer (apache-tomcat-6.0.36.exe) Mac – Unzip

14 Outline Tomcat Basics Tomcat Administration Deploy web applications to Tomcat server – WAR file – Deployment folder

15 Look inside the Tomcat directory /tomcat /bin startup.sh shutdown.sh /conf server.xml /lib/logs/webapps /ROOT/deployedApp1 /WEB-INF web.xml /lib /classes /META-INF /deployedApp2 /work

16 Start Tomcat Server Windows > startup.bat Mac $ cd “TOMCAT_HOME”/bin $./startup.sh Test – http://localhost:8080 http://localhost:8080

17 Shut Down Tomcat Server Windows > shutdown.bat Mac $ cd “TOMCAT_HOME”/bin $./shutdown.sh Test – http://localhost:8080 http://localhost:8080

18 Look inside the Tomcat directory /tomcat /bin startup.sh shutdown.sh /conf server.xml /lib/logs/webapps /ROOT/deployedApp1 /WEB-INF web.xml /lib /classes /META-INF /deployedApp2 /work

19 Tomcat Architecture Connector HTTP 1.1 Connector HTTP 1.1 Web application A Connector AJP 1.3 Connector AJP 1.3 Web application B Web application C Web application D HTTP Request HTTP Response AJP Response AJP Request TOMCAT Engine Host Context More about server.xml: http://www.mulesoft.com/tomcat-configuration#.URM9VlqWkSg

20 Host, Context Host http://chausie.slis.indiana.edu/ http://localhost:8080/ Context http://chausie.slis.indiana.edu/ROOT http://localhost:8080/myApp

21 Tomcat configuration file (server.xml) <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> <Host name="localhost" appBase="webapps” unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">

22 Change Default Port In “server.xml” … <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> … <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> …

23 Change Default Port In “server.xml” … <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> … <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> …

24 Outline Tomcat Basics Tomcat Administration Deploy web applications to Tomcat server – WAR file – Deployment folder

25 Package your web application Export your project to as a WAR file. – A WAR file (or Web application ARchive) is a JAR file used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, tag libraries, static web pages (HTML and related files) and other resources that together constitute a web application. http://en.wikipedia.org/wiki/WAR_(file_format)

26 Package your web application In Eclipse, right click on your project name; go to “Export”, and click “WAR file ”.

27 Package your web application Click “Browse” to select a location to store your WAR file, and click “Finish”.

28 Deploy your web application Copy your WAR file to the TOMCAT_HOME/webapps directory. Restart Tomcat. –./shutdown.sh –./startup.sh Test http://localhost:8080/myApp/Web_compute Check the TOMCAT_HOME/webapps directory. A new directory named “myApp” is created.

29 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img

30 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img This is the root directory of the web application. All static content (e.g. HTML files, images) are stored here.

31 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img WEB-INF directory is not part of the public document.

32 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img This directory is where servlet and utility classes are located.

33 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img This directory contains Java Archive files that the web application depends upon. For example, this is where you would place a JAR file that contained a JDBC driver.

34 Look inside your application directory /myApp /WEB-INF /classes /lib web.xml Index.html/img web application deployment descriptor

35 Web Application Deployment Descriptor: web.xml myApp index.html index.htm index.jsp default.html default.htm default.jsp Web_compute Web_compute /Web_compute

36 Welcome page The welcome-file-list element contains a list of file names When the URL request is a directory name, Tomcat automatically brings the first file on the list If that file is not found, the server then tries the next file in the list, and so on This file can be of any type, e.g., HTML, JSP, image, etc. index.html index.htm index.jsp default.html default.htm default.jsp index.html index.htm index.jsp default.html default.htm default.jsp

37 Welcome page The welcome-file-list element contains a list of file names When the URL request is a directory name, Tomcat automatically brings the first file on the list If that file is not found, the server then tries the next file in the list, and so on This file can be of any type, e.g., HTML, JSP, image, etc. Web_compute index.htm index.jsp default.html default.htm default.jsp Web_compute index.htm index.jsp default.html default.htm default.jsp

38 Servlet Declaration and Mapping The element declares a Servlet The element maps a URL to a specific Servlet – The URL is relative to the application’s base URL ( http://localhost:8080/myApp/ ) Web_compute Web_compute /Web_compute Web_compute Web_compute /Web_compute

39 Servlet Declaration and Mapping The element declares a Servlet The element maps a URL to a specific Servlet – The URL is relative to the application’s base URL ( http://localhost:8080/myApp/ ) Web_compute Web_compute /Web_compute Web_compute Web_compute /Web_compute

40 Work Flow The user submits an HTTP request Tomcat finds the servlet based on the URL and the deployment descriptor ( web.xml ) and passes the request to the servlet The servlet writes an HTML page containing the response Tomcat returns the HTML page to the user

41 References http://www.mulesoft.com/tomcat-configuration- step-step-guide#.URM9VlqWkSg www.cis.upenn.edu/~matuszek/cit597- 2004/Lectures/26-tomcat.ppt www.cis.upenn.edu/~matuszek/cit597- 2004/Lectures/26-tomcat.ppt http://en.wikipedia.org/wiki/Apache_Tomcat http://www.mulesoft.com/tomcat-configuration- step-step-guide#.URM9VlqWkSg http://www.mulesoft.com/tomcat-configuration- step-step-guide#.URM9VlqWkSg http://www.ntu.edu.sg/home/ehchua/programm ing/howto/Tomcat_HowTo.html

42 Questions? chunguo@indiana.edu


Download ppt "Deploying Web Applications to Tomcat Server Chun Guo"

Similar presentations


Ads by Google