java left logo
java middle logo
java right logo
 


 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4089
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
Introduction to Java Servlets with Eclipse E-mail
User Rating: / 1359
PoorBest 

How to Start Tomcat Manually

If you have successfully configured Tomcat, you should have a bin folder of Tomcat. Remember that you need to download the Tomcat from Apache website in the form of zip file. Do not download the .exe file as it would be good if you have a manual hands-on experience on this. It should help you to understand how Tomcat works.



Image

I have extracted my Tomcat into C:\tomcat-5.5.16. Thus, I should have a bin folder that is C:\tomcat-5.5.16\bin.



Image

If you pay attention carefully, you would see there is startup.bat and shutdown.bat. These two files are used to start Tomcat and shutdown Tomcat respectively.

Double click on startup.bat, a new Tomcat console should open. Watch the console carefully and you will see something interesting.



Image

You should see that it displays “Deploying web application archive MyFirstServlet.war”. Tomcat always checks its webapps folder whether is there any WAR file. If so, it will extract it and deploy it to its container so that we can run it after Tomcat started. Tomcat will be started if you have seen the message “Server startup in N ms”. If you do not have any WAR file, the above message should not be displayed.

Now, open your browser and go to http://localhost:8080.



Image

This means that we have started Tomcat correctly. As we have already deployed our MyFirstServlet, execute it by http://localhost:8080/[yourwebappname] so it would be http://localhost:8080/MyFirstServlet.



Image

Awesome! Try to press Submit button, it should do nothing as we have not specified any action in our <form></form> tag. Next, we need to modify our index.jsp to call our Java Servlet to greet the user and to redirect the user to the success page.

Please remember not to shutdown the Tomcat by clicking on the close window on the Tomcat console. Please use the shutdown.bat instead as it helps Tomcat to gradually shutting down itself.

Now, let’s create our Java Servlet. You can right click on the src folder (this is your source folder) and choose New and Others. A wizard will be prompted to you to configure your Java Servlet.



Image

Go to the Web, choose Servlet and press Next button.



Image

In this wizard, you may define the package for your Java Servlet. Normally, we use Package to group a few Java files that has the same functionalities. For example, if I have StringUtil.java for String manipulation and EncodingAlgorithmUtil.java for encoding, I will locate them under the same package called “com.mycompanyname.util” as they both are actually utility classes. So as this is our first Java Servlet, let’s create one package called “com.mycompany.servlet”. The class name is basically your Java Servlet name. To make it self-explanatory, I name it GreetingServlet. You can leave other configuration as they are.

Then press Next button.



Image

In the second step of the Java Servlet configuration, you may or may not provide any description that you want for your Java Servlet. Initialization Parameter is extremely useful if your Java Servlet need to have initial value before being executed. The URL mapping is used to identify on how the Java Servlet should be called. This is the URL that is called in your <form></form> tag in JSP file. If you set the URL Mapping into /test/GreetingServlet, you need to call it as /test/GreetingServlet from your <form></form> tag in your JSP file.



Image

In the last step of Java Servlet configuration, we can keep them as they are. This wizard allows you to modify your Java Servlet’s methods. Press Finish button and we have created a non-functional Java Servlet.



Image

If you have followed correctly, you should have a GreetingServlet.java similar to the illustration below.



Image



 
< Prev   Next >
Posted by Prabhu, prabhurangasamy@gmail.com on Tuesday, 27 June 2006 at 9:17

Hai guys. This is the best, best, best website which gives me an idea for using the webtools platform of eclipse.


 1 
Page 1 of 1 ( 1 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.