Magazine
 

JBoss Seam : Stitching JSF and EJB3

temp:

This is a directory used by the AutoDeployer to store files temporarily.

webapps:

This directory may be considered as a main directory; in which, all deployed web applications are put up including necessary files such as class file, xml file, html file, jar
file, etc. These files are put up restrictedly according to the deployment directory structure.

work:

This folder is automatically generated by Tomcat, where Tomcat places intermediate files (such as compiled JSP files) during its work. You will not be able to execute JSP
pages if you delete this directory while Tomcat is running.

Running a Servlet on the Tomcat Server

Now, lets see how a web application is run on the Tomcat server taking an example of servlet. Once you have installed the Tomcat then do the following steps:

1 Set all three paths (such as JDK path, classpath, and Java_Home path) as:

 

set path =%path% C:\Program
Files\Java\jdk1.6.0\bin;
set classpath =%CLASSPATH%
C:\Tomcat6.0\lib\ servlet-api.jar;
set JAVA_HOME=C:\Program
Files\Java\jdk1.6.0;

2 Create a servlet class as HelloWorld.java and compile it to make a class file of it. import java.io.*;

 
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet{
public void doGet(HttpServletRequest
request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType(“text/html”);
PrintWriter pw = response.getWriter();
pw.println(“<html>”);
pw.println(“<head><title>Hello World
</title></title>”);
pw.println(“<body>”);
pw.println(“<h1>Hello World</h1>”);
pw.println(“</body></html>”);
}
}

3 Create an xml descriptor file as web.xml.

<?xml version=”1.0" encoding=”ISO-8859-
1"?>
<!—<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD
Web Application 2.3//EN”
“http://java.sun.com/dtd/webapp_
2_3.dtd”> —>
<web-app>
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/HelloWorld</url-pattern>
</servlet-mapping>
</web-app>

4 Make a Web-application directory structure under the webapps directory shown as

Dec 2007 | Java Jazz Up | 16
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF