Download and Install : download and install the latest version of apache Tomcat Web server from http://tomcat.apache.org/download-60.cgi
Once downloaded , Extract thezip file to find the folder structure similar to the one in Fugure.1 below.

Figure.1
Every Tomcat (or webserevr) download will have 2 parts: the Servlet container named Catalina and the JSP engine named Jasper.The webapps folder in the main folder depicts the default web-application which would be executed when the server is started and requested via weburl.
Make sure that either the
1)JAVA_HOME environment variable is set to its Java's jdk root folder.
or
2) JRE_HOME environment variable is set to its Java's jre root folder
If you don't have JAVA installed go an download the JDK from the Sun Download page .(reference:http://www.cristhianny.com/others/tomcat5_setup_first_servlet.html)
Now, we need to set the Environment variable for the servlet container as 'CATALINA_HOME' for the root directory of the WebServer, which is c:\tomcat7.0.
Starting your Tomcat Server:
traverse to your tomcat bin folder in your command prompt and execute the command 'startup' .
(or)
just execute the command %CATALINA_HOME%\bin\startup in your command prompt.
Note: This command wouldn't work if your java environment variable isn't set correctly.
Testing of server setup: The default webapplication can be tested by browsing the url , http://localhost:8080/
Some common errors and troubleshooting techniques whie testing:
1) If the testing of the web app fails, It could be since the port 8080, which is the default http post is already in use. In this case, the port number could be changed to somethin greater than 1024. But when doing so, we need to remember the 2 changes; one if the url and the other in the server.xml file in the conf folder of the server.
2)Another error is when the Localhost isn't found. This can be rectified by altering the LAN setting and altering the server behind the proxy.(google...)
Common Note:Other coomon Application servers apart from Apache Tomcat are: BEA Weblogic and IBM Websphere
------------------------------------------------------------
TOMCAT CONTEXTS :
(reference:http://www.cristhianny.com/others/tomcat5_setup_first_servlet.html)
A context is a 'folder structure' where you will store your web application files (html, jsp, servlets, images, flash, etc...). You can have a different context for every web application that is running on your server. The contexts are stored in $CATALINA_HOME/webapps/
For instance, if i am working in 2 web applications called "app1" and "app2" then i can crate 2 folder with the same name inside $CATALINA_HOME/webapps/. Just be sure to follow the following conventions when creating a context:
Let's say i want to create a project called app1, then i would have the following folder structure at $CATALINA_HOME/webapps/:
$CATALINA_HOME/webapps/ app1/
- WEB-INF/
- src/
- classes/
- lib/
- web.xml
- Basically, web.xml is the configuration file of our context or web application.
- IN src we will have our java source files /Servlets source code. But we will only have the .java files, not the .class files there.
- In the folder app1 we can put our jsp pages or html pages
- In lib we will have jars,like database jdbc drivers and other vendors' libraries.
- In classes we will have the .class which are our servlets.
No comments:
Post a Comment