Tomcat Setup
How the Tomcat is set up
· Copy the image files watermelon.PNG, apple.PNG, orange.PNG, banana.PNG, and noimage.PNG into the <Tomcat 5.5 Program Directory>\webapps\ShowFruits\images directory.
· Open the file fruitServlet.java and save it in the MySamples NetBeans project.
· This file contains a servlet that will access the 'fruits' dsn we just created and output the information in the fruitlist table onto a web page.
· Compile fruitServlet.java and copy fruitServlet.class (in MySamples\build\classes) onto <Tomcat 5.5 Program Directory>\webapps\ShowFruits\WEB-INFO\classes
· Now, add the following entries to web.xml for the fruitServlet. As mentioned before, paste the 'servlet' tag under the 'servlet' tags already in the file. Paste the 'servlet-mapping' tag under the existing 'servlet-mapping' tags.
Important: All the 'servlet' tags should be in a group and all the 'servlet-mapping' tags should be in another group below the 'servlet' tags; do not pair a class's servlet and servlet mapping tags together.
Under servlet tags: <servlet> <servlet-name>ShowFruits_servlet</servlet-name> <servlet-class>fruitServlet</servlet-class> </servlet> Under Servlet mapping tags: <servlet-mapping> <servlet-name>ShowFruits_servlet</servlet-name> <url-pattern>/fruitsFromDB</url-pattern> </servlet-mapping>
· Now, reload or stop and start the ShowFruits application using the Tomcat Manager page.
· Enter the following URL : http://localhost:8080/ShowFruits/fruitsFromDB
· You will see a table containing all the fruits in the fruitlist table in the fruits.mdb MS Access database.
· Test the servlet by adding entries to the table and running the program again (remember to add the corresponding image to the ShowFruits\images subfolder in Tomcat)