Tested with latest builds of NetBeans 6.5, Eclipse Europa (3.3.1) and Ganymede (3.4), Apache Tomcat 6.0.14, using JDK 1.6.0_03 on Ubuntu GNU/Linux 7.10. NetBeans is supposed to be installed using the bundled Tomcat 6.0.14 container.
Once in your Eclipse workspace, use the "New" -> "Project" wizard to create a "Dynamic Web Project" like this:
In our example, this project will be named foobar as the name obviously doesn't matter:
In most cases (if you do have a running web dev workspace), you are likely to have a servlet container / application server configuration already around and working, otherwise please click the "New" button right of "Target Runtime" combo box and follow the next steps to add a new Apache Tomcat runtime configuration:
By then, browse to the folder of your local Tomcat installation (CATALINA_HOME, if you're familiar with running Tomcat from the shell) and finish creating your server runtime as well as creating your project:
By then, you should see an empty Eclipse WTP project structure looking more or less like that:
To do our demonstration, we want to add an empty JSP as well as an empty servlet and make them generate some (pointless yet working) output. First, the JSP: Right-click the "foobar" project in your workspace, choose "New" and then "JSP":
The file will be located in the WebContent folder of your project and be named "foo.jsp", for the sake of consistency. By then, you'll see that Eclipse has already opened the newly created file in an editor for you to insert something meaningful (like the "h1" statement shown in the image):
Next, the servlet. Again, right-click the project and choose "New" -> "Servlet", to create an EmptyServlet class in the foobar package:
Again, you're provided with an editor to actually put code to the servlet, please modify the doGet(...) method as outlined in the next picture:
By now, we're ready to test-drive this (rather simple) application on our local Tomcat server. For that, again right-click the project, choose "Run" -> "Run on server"...,
... keep all settings at the default and proceed clicking "Finish". By then, a browser window will open inside the Eclipse workspace showing an error (which is because we haven't set an index.jsp and/or handled the welcome page call in another meaningful way. However by now we should be capable of both running our JSP file...
... and our servlet file by using the appropriate URL mappings in the browser window:
So far, so good. Now let's stop Tomcat using the "Big Red Button" in the lower right of your workspace...
and move forth.
Start with importing Eclipse project to NetBeans via "File" -> "Import Project" -> "Eclipse Project", choose the Eclipse workspace to contain your 'foobar' project:
... select the right project:
... select application server to use and press Finish to start import:
Eclipse project imported to NetBeans will look like this:
Press F6 (or via menu Run -> Run Project) and you get the same result as when executed from Eclipse. (Note: before running project from NetBeans you may want to stop Tomcat server in Eclipse otherwise you will get an error that port is already in use)
| 01-newweb-eclipse.jpg | ![]() |
22879 bytes |
| 02-newweb-eclipse-appsrv-1.jpg | ![]() |
40616 bytes |
| 02-newweb-eclipse-appsrv-2.jpg | ![]() |
26751 bytes |
| 03-newweb-eclipse-2.jpg | ![]() |
53609 bytes |
| 04-webproject-empty.jpg | ![]() |
9342 bytes |
| 05-jsp.jpg | ![]() |
35910 bytes |
| 06-jsp-edit.jpg | ![]() |
26526 bytes |
| 07-servlet.jpg | ![]() |
34423 bytes |
| 08-servlet-edit.jpg | ![]() |
45668 bytes |
| 09-runonserver.jpg | ![]() |
50117 bytes |
| 10-run-jsp.jpg | ![]() |
12188 bytes |
| 11-run-servlet.jpg | ![]() |
12854 bytes |
| 12-tomcat-stop.jpg | ![]() |
14232 bytes |
| 13-nb-eclipse-import-1.jpg | ![]() |
52126 bytes |
| 13-nb-eclipse-import-1.png | ![]() |
47558 bytes |
| 14-nb-eclipse-import-2.jpg | ![]() |
30197 bytes |
| 14-nb-eclipse-import-2.png | ![]() |
43153 bytes |
| 14-nb-eclipse-import-3.png | ![]() |
33729 bytes |
| 15-nb-afterimport.jpg | ![]() |
12351 bytes |
| 15-nb-afterimport.png | ![]() |
99074 bytes |
| 16-nb-newweb.jpg | ![]() |
47995 bytes |
| 17-nb-newweb-2.jpg | ![]() |
43878 bytes |
| 18-nb-emptyweb.jpg | ![]() |
23946 bytes |
| 19-nb-favorites-workspace.jpg | ![]() |
26351 bytes |
| 20-nb-project-aftercopy.jpg | ![]() |
18648 bytes |