eclipse是open source的集成开发环境,它得到了ibm的大力支持,而tomcat我们就更熟悉了,它是apache组织的jsp/servlet容器,下面将讲述如何集成:
准备:
1. tomcat4.0
2. jdk1.4
3. eclipse2.0
4. eclipse的tomcat插件在http://www.sysdeo.com/eclipse/tomcatpluginv2.zip下载
安装:
1. 安装jdk1.4
2. 安装tomcat4.0
3. 安装eclipse2.0,解压缩就可以了
4. 将tomcatpluginv2.zip解压缩,把其中的com.sysdeo.eclipse.tomcat文件夹拷贝到,eclipse安装目录下的plugins目录中。
配置:
1. 启动eclipse
2. 打开菜单windows->preferences
3. 在左侧选择tomcat,可以看到右侧出现一些表单
4. tomcat version选择version 4.0.x,tomcat home选择tomcat的安装路径,configuration file中会自动填入tomcat的配置文件server.xml
5. 展开左侧的tomcat菜单,选择jvm settings,jre选择detected vm,
6. 按下apply
7. 按下ok
8. 看你的工具栏中是不是多了几个小猫的图标,如果没有的话,选择菜单windows ->custmize perspective,展开other选项,在tomcat上打勾,好了,看到小猫的图标没有。
9. 试下start tomcat按钮,好了,tomcat在console中启动了。
例子:
下面做个hello world的例子
1. 选择file->new->project
2. 在对话框中选择tomcat project,然后next
3. 输入project name,这里可以写helloworld,继续next
4. 勾上can update server.xml file选项,finish,好了,一个poject已经创建好了。
5. 打开new class 向导,在name中填入helloworld,在superclass中填入javax.servlet.http.httpservlet,按下finish,好了,一个servlet就创建好了
6. 在helloworld.java中重载doget方法,代码如下:
import javax.servlet.http.httpservlet;
import javax.servlet.http.httpservlet;
import javax.servlet.http.httpservletrequest;
import javax.servlet.http.httpservletresponse;
import java.io.ioexception;
import java.io.printwriter;
import javax.servlet.servletexception;
public class helloworld extends httpservlet {
public void doget(httpservletrequest request,httpservletresponse response)
throws ioexception, servletexception {
response.setcontenttype("text/html");
printwriter writer = response.getwriter();
writer.println("hello world!");
}
}
8.ctrl+s保存,右键helloworld project,选择tomcat project->update context to server.xml
7.在eclipse中启动tomcat
9.在用浏览器访问http://localhost:8080/helloworld/servlet/helloworld
10.怎么样,看到helloworld了没有
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器