选择显示字体大小

eclipse+tomcat集成开发servlet

eclipse是open source的集成开发环境,它得到了ibm的大力支持,而tomcat我们就更熟悉了,它是apache组织的jsp/servlet容器,下面将讲述如何集成:

准备:

1. tomcat4.0

2. jdk1.4

3. eclipse2.0

4. eclipsetomcat插件在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   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons