Probably You always wanted to write your own web-based application in Java (ok, read: writing another Facebook-like portal and live in luxury in Dubai to the end of Your life ;-)). Of course it is possible, but before that inevitable moment occurs, You have to do much more simple thing - configure the environment for developing web applications (unless You are headmaster in Your own company and someone else does it for you...).
So let's look at how to configure Apache Tomcat which is professionally defined as the servlet container (i.e. for JSP). I will show how to configure it under Eclipse and NetBeans.
--------------------------------------------
Eclipse:
Recall that so far we have managed to install Java and set up Eclipse to work with it. It is time for Tomcat.
Step 1: download the Tomcat binary distribution (core version as a .zip file) from here (use current Tomcat 6.x version, 6.0.32 - edited on Tuesday, July 26, 2011)
Step 2: Unpack the .zip from step 1 to the C:\Development\Tomcat_Eclipse directory. We should get something like this:
Step 3: Open Eclipse IDE and the Java EE perspective (Window menu -> Open Perspective -> Other -> Java EE). This will be the default perspective for our work. Using this perspective, at the bottom in the "Servers" tab we add a new server:
Step 4: Configure the new server. Select the type of the server in accordance with step 1 (Tomcat 6), and leave the name set to localhost:
Step 5: Further configuration of the new server. Select the server's installation directory and Java virtual machine which will be used - in this case it will be the same virtual machine which we configured to work with Eclipse (description here).
Step 6: Basic configuration of a server
First we allow the Eclipse to manage Tomcat installation (so we can start and stop the server directly from Eclipse). Second we change the "deploy-path" from proposed to the Tomcat default webapps directory (in our case C:\Development\Tomcat\webapps) - it is the default directory where Tomcat keeps web applications. The third and final thing is to change the way Tomcat publish applications on the server - each application will have a separate xml configuration file in Tomcat (so-called "context" file).
Tomcat is ready and configured to work. We can start and stop it using the icons on the right side in the "Servers" tab. The results of these operations (logs), are visible in the "Console" tab.
--------------------------------------------
NetBeans:
We do not need to install Tomcat under NetBeans - provided that we followed instructions from this post. We should have Tomcat installed.
If we did not install Tomcat during NetBeans installation, we can do it similar like for Eclipse. Just unpack the Tomcat to specified directory, start NetBeans and go to the Tools -> Servers -> Add Server:
The rest of the installation steps are similar to that of Eclipse and it should not cause trouble.
No comments:
Post a Comment