Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 8 Anzeige

Weitere Verwandte Inhalte

Aktuellste (20)

Anzeige

bjhbj

  1. 1. Apache Tomcat Assignment 1.Use your own words; what does JVM mean? Answer: The Java Virtual Machine is a program whose purpose is to execute other programs, executes code and provides the runtime environment for that code. The JVM has two primary functions: -Allow Java programs to run on any device or operating system -Manage and optimize program memory. 2.What does “application server” mean? Answer: An application server’s fundamental job is to provide its clients with access to what is commonly called business logic, which generates dynamic content; that is, it’s code that transforms data to provide the specialized functionality offered by a business, service, or application. While the web server‘s fundamental job is to accept and fulfill requests from clients for static content from a website (HTML pages, files, images, video, and so on). The client is almost always a browser or mobile application and the request takes the form of a Hypertext Transfer Protocol (HTTP) message, as does the web server’s response. 3.Use your own words; what is a WAR file, and how tomcat deals with it? And where it should be to be deployed? Answer: - A WAR file stands for Web Application Archive and is a bundle for distributing or hosting a java web application. It is used as a bundle of files required by the web application that is written in Java programming language. A war file may contain following file types: Application code in the form of class files Servlets(which are also class files), JSPs, Application’s deployment descriptor(web.xml), JAR files required by the application class files, Static files such as images and html files etc. - Tomcat deals with WAR files packaging them for deployment. These files can be created on the command line or with an IDE like Eclipse. After deploying our WAR file, Tomcat unpacks it and stores all project files in the webapps directory in a new directory named after the project. -The Tomcat deploying WAR files in the webapps directory : $CATALINA_BASE/webapps.
  2. 2. 4.Let’s assume that you have a Java web application, and this application needs to be deployed on a server that is totally fresh and does not have any per-prepared infrastructure. List the steps needed to deploy this web application (over tomcat application server)? A. Start Tomcat B. Configure Roles vim /etc/tomcat9/tomcat-users.xml: <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="password" roles="manager-gui, manager-script"/> C. Copy the WAR file to tomcat9/webapps as below: 5.Use your own words; is running multiple instances of tomcat on one server, benefits or not? And why? Yes , it’s beneficial because of providing the isolation by accessing different applications through different ports on same host ,vastly more maintainable and secure but is slightly more resource-intensive and multiple tomcat instances allow to share common binaries and underlying OS resources.
  3. 3. 6.You have two Java web applications, and one of them shall be accessible from outside the server, and one shall not be accessible except from localhost (http://localhost). How to configure this? And what is the file to configure? (Write a sample down). Answer: by adding the following filter into the web.xml file <filter> <filter-name>Remote Address Filter</filter-name> <filter-class>org.apache.catalina.filters.RemoteAddrFilter</filter-class> <init-param> <param-name>allow</param-name> <param-value>127.d+.d+.d+|::1|0:0:0:0:0:0:0:1</param-value> </init-param> </filter> <filter-mapping> <filter-name>Remote Address Filter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
  4. 4. - Access denied outside the machine: -From the localhost is fine
  5. 5. 7.Practical: initiate two instances of tomcat 8, and run one of them over HTTPS, and the other over HTTP. (You can use the default application installed with tomcat), (Use self-signed certificate). Answer: - generate the certificate keytool -genkey -keystore keystore.jks -alias codez.jks -keyalg RSA -sigalg SHA256withRSA -validity 365 -keysize 2048 Configuring in the server.xml as below:
  6. 6. Checking first instance https-port:”8443”:
  7. 7. - Second instance on http-port “8181” Hide the the version of tomcat: Steps : cd /home/tomcat/lib mkdir -p org/apache/catalina/util Go to this newly created directory, and create a ServerInfo.properties file, and add the server.info parameter as shown below. Set the value of this parameter to anything you like. cd org/apache/catalina/util $ vi ServerInfo.properties server.info=Apache Tomcat Version X Afer this restart the tomcat server. cd $CATALINA_HOME/bin ./catalina.sh stop ./catalina.sh start
  8. 8. -------------------------------------------------------------------------END :) ---------------------------------------------------------------------------

×