Magazine
 
ANT
 

public void service(HttpServletRequest
request, HttpServletResponse response)
throws IOException, ServletException{
response.setContentType(“text/html”);
PrintWriter out = response.getWriter();
out.println(“<html>”);
out.println(“<head>”);
out.println(“<title>Hello World Servlet!
</title>”);
out.println(“</head>”);
out.println(“<body>”);
out.println(“<p align=\”center\”><font
size=\”5\” color=\”#000080\”>Hello
World! </font></p>”);
out.println(“<p align=\”center\”><a
href=\”javascript:history.back()\”>
Go to Home</a></p>”);
out.println(“</body>”);
out.println(“</html>”);
}
}

Here is the code of index.jsp file:

<%@page language=”java” %>
<html>
<head>
<title>Welcome to JBoss 3.2.3 World</title>
</head>
<body bgcolor=”#FFFFCC”>
<p align=”center”><font size=”6"
color=”#800000">Welcome to<br>
Jboss 3.2.3 World</font></p>
<p align=”center”>
<font color=”#000080"
size=”4">Congratulations you have
successfully installed it </font></p>
<p align=”center”>
<font color=”#000080" size=”4">
<a href=”servlet/HelloWorld”>Click here to</
a> execute Hello World Servlet.
</font>
</p>
</body>
</html>

Download all the files for this section from
here.

  Writing Application and Web deployment
descriptor
 

Since in this section we are developing one servlet and one jsp file so our deployment descriptor is very simple.
web.xml file::

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

application.xml file:

<?xml version=”1.0" encoding=”ISO-8859-
1"?>
<application>
<display-name>Example 2 </display-name>
<module>
<web>
<web-uri>example2.war</web-uri>
<context-root>/example2</context-root>
</web>
</module>
</application>

Above application.xml file describe the content of example2.ear. Tag <web-uri>example2.war</web-uri>
describe the name of web module (i.e.. example2.war) packaged in the archive. The context root of this example2.ear is eample2.

Writing Ant build xml file To build example2.ear file, I have written build.xml which compiles source code and builds deployable archive file. build.xml file:

 Dec 2007 | Java Jazz Up |38
 
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