Showing posts with label Apache Tomcat .. Show all posts
Showing posts with label Apache Tomcat .. Show all posts

Wednesday, 17 September 2014

Hosting two webapps on one tomcat

Assumptions - 

  1. Assume you have a development host with two host names, localhost and localhost1(You will need to create a hosts file entry for this or you can simply put the LAN ip address if you want)
  2. Let's also assume one instance of Tomcat running, so $CATALINA_HOME refers to wherever it's installed, may be some where in /var/lib/tomcat7 (Please use it according to the location and the operating system you are using )

What to change??

  1. Definitely server.xml !!! 
  2. You will find server.xml in /var/lib/tomcat7/conf/server.xml or you may use find command if you have no idea where you will get it. For the list of commands in linux and their brief summary please check here 

Default entry in server.xml is 



 <Engine defaulthost="localhost" name="Catalina"></Engine>  

You need to add this - 

 <Engine name="Catalina" defaultHost="localhost">  
   <Host name="localhost"  appBase="webapps"/>  
   <Host name="localhost1" appBase="my_webapps"/>  
 </Engine>  

Wednesday, 3 September 2014

Servlets in Java

Servlets in breif 

            A servlet is a Java technology based web component, managed by a container, that generates dynamic content. A servlet can be considered as a tiny Java program which processes user request and generates dynamic content.
Following are the some advantages of using servlets.
(1) They are generally much faster than CGI scripts.
(2) They use a standard API that is supported by many web servers.
(3) They have all the advantages of the Java programming language, including
    ease of development and platform independence.
(4) They can access the large set of APIs available for the Java platform.

What is a Servlet Container?

           Servlet container (also known as servlet engine) is a runtime environment, which implements servlet API and manages life cycle of servlet components.Container is responsible for instantiating, invoking, and destroying servlet components.One example of container is Apache Tomcat which is an opensource container.