|
Server |
|
A web application is a structured hierarchy of
directories. The folder webapps is the home
directory of Tomcat web server. This is the
main folder for the “public” section. The MI
framework and applications will be stored in
the JavaJazzup folder and its subfolders.
A special directory exists within this
application hierarchy called WEB-INF. The
WEB-INF folder is the main folder of the “private” section of a Web application.
5. Take your compiled servlet class file as "HelloWorld.class” and place them in the WEB-INF/classes directory. If you have
defined your servlet to belong in a package,
you must follow the standard Java rules and
create the appropriate subdirectories so the
JVM will be able to find your classes.
6. Put the created xml file as “web.xml” file
in the WEB-INF directory. This XML file is the
deployment descriptor for servlets and other
components that make up the application.
7. To test your servlet, start the Tomcat
server clicking the startup.bat file from the
bin directory. |
|
8. Once the server is start, open a Web
browser, and open a URL of the following
form:
http://{address}:{port}/{servletName}
where:
- address is the name or IP address of
the machine running Tomcat. You can
use localhost if the browser is running
on the same machine as Tomcat.
- port is the port on which Tomcat is
listening. By default, that is port 8080.
- servletName is the name of the servlet
you want to invoke. That should match
the value contained in the <urlpattern></
url-pattern> tags in the
web.xml deployment descriptor file.
For example, if Tomcat is running on the same
machine as the browser and listening on the
default port (8080), you can test HelloWorld
servlet by opening the following URL:
http://localhost:8080/JavaJazzup/HelloWorld
The output of the program is given below:
|
|
Dec 2007 | Java Jazz Up | 17 |
|
|
|
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 |
|
|
|
|
|
|
|
|
|