jump to navigation

Servlets using Eclipse & Tomcat August 17, 2005

Posted by Coolguy in Eclipse.
trackback

Download

Steps:

  • Open the J2EE Perspective. Window->Open Perspective->Other…->J2EE.
  • Set up XDoclet preferences. Window->Preferences->J2EE Annotations->XDoclet. Make sure the “Enable XDoclet Builder” option is checked. Select your desired version level and navigate to your XDoclet home directory. Hit OK
  • Add the Tomcat server. Window->Preferences->Server->Installed Runtimes. Hit the “Add” button.
  • Select the appropriate Apache Tomcat level for your Tomcat server and hit the “Next” button. Fill in the appropriate Tomcat home directory. Hit the “Finish” button
  • From the J2EE Project Explorer, right click on the “Dynamic Web Projects” group. Select New->Dynamic Web Project.
  • Type the project name, “HelloWorld”. Make sure the “Add Module to EAR project” selection is unchecked. Tomcat does not support the use of EAR projects so we will only make a stand alone web application
  • Expand the “Dynamic Web Projects” group to the HelloWorld web project, and then to the “Servlets” catgeory.
  • Right click on “Servlets” and select New->Servlet
  • Select the doDelete and doPut method checkboxes in addition to the defaults.
  • Hit “Finish” to create the non annotated servlet.
  • Double click on the HelloWorld class in the Project Explorer. Add the following code to the doGet method:
  • PrintWriter out = new PrintWriter(System.out); out = response.getWriter(); out.println(“Hello world!”);out.close();
  • Save and close the editor
  • Select the “HelloWorld” web project. Right click and select Run As->Run on Server
  • Choose to manually define a new Server. Select the Apache Tomcat version you have installed. Hit next
  • Bingo !!

More:

http://www.eclipse.org/webtools/jst/components/j2ee/scenarios/ServletScenario.html

Advertisements

Comments»

No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: