| 
                 
             | 
			 
				- 
					First set up Tomcat Runtime from the
					Windows->Preferences->Server->Installed Runtime.
					
 
					 
					 
					 
					 
					
						Figure 1: Setup the Tomcat Runtime from
						Windows->Preferences->Server->Installed Runtime.
					
				 
				 
				 
				- 
					Open J2EE perspective, from the Dynamic Web Projects, right click
					and choose "New" and then choose "J2EE Web Project"
					
						
							
								 
							 | 
							
								 
							 | 
						 
						
							| 
								 
									Figure 2: Open the J2EE Perspective.
								 
							 | 
						 
					 
					
						
							| 
								 
									 
								 
							 | 
						 
						
							| 
								 
									
										Figure 3: Enter the name of the new Project,
										select your Target runtime, and uncheck "Add
										module to EAR project".
									
								 
							 | 
						 
					 
				 
				 
				 
				- 
					Create a servlet by right clicking on the web project you
					created, select "New>Class"..
					
						
							| 
								 
									 
								 
							 | 
						 
						
							| 
								 
									
										Figure 4: Enter a Java package and Java name.
										Select
										javax.servlet.http.HttpServlet
										as the super class.
									
								 
							 | 
						 
					 
				 
				 
				 
				- 
					Open the new HeaderSnoop.java under "TestWebProject/Java
					Resources/JavaSource//HeaderSnoop.java" and copy following method
					into the body of the file:
					
public void doGet(HttpServletRequest req, HttpServletResponse resp) 
		throws ServletException, IOException
{
	resp.setContentType("text/plain"); 
	PrintWriter out = resp.getWriter(); 
	Enumeration names = req.getHeaderNames();
	while(names.hasMoreElements()) { 
		String name = (String)names.nextElement(); 
		String val = req.getHeader(name); 
		if( val != null ) { 
			out.println(name+":"+val ); 
		} 
	} 
}
					
				 
				 
				 
				- 
					Add the following declaration to your web.xml after the
					display-name element:
					
<servlet>
	<servlet-name>HeaderSnoop</servlet-name>
	<servlet-class>org.test.HeaderSnoop</servlet-class>
	</servlet> <servlet-mapping>
	<servlet-name>HeaderSnoop</servlet-name>
	<url-pattern>/HeaderSnoop</url-pattern>
</servlet-mapping>
					 
				 
				 
				 
				- 
					Configure Tomcat from the Servers view in the J2EE perspective
					
						
							| 
								 
									 
								 
							 | 
						 
						
							| 
								 
									
										Figure 5: By default, the available module
										groupings are presented to the user.
									
								 
							 | 
						 
					 
				 
				 
				 
				- 
					Hit finish and you will see following
					
						
							| 
								 
									 
								 
							 | 
						 
						
							| 
								 
									
										Figure 6: By default, the available module
										groupings are presented to the user.
									
								 
							 | 
						 
					 
				 
				 
				 
				- 
					Go to the project in the Project Explorer, select the web
					project, right click and select "Run As", you will see Apache
					Tomcat, create runtime configuration for the web project by
					selecting "New" button.
					
						
							| 
								 
									 
								 
							 | 
						 
						
							| 
								 
									
										Figure 7: By default, the available module
										groupings are presented to the user.
									
								 
							 | 
						 
					 
				 
				 
				- 
					Now Run the server from the Servers view, and view the servlet.
				
 
			 
		 |