首先下载tomcat插件: http://www.eclipsetotale.com/tomcatPlugin.html,下载最新的3.3版本;

由于我的eclipse是通过yum自动安装的,因此eclipse在默认的路径下/usr/lib/eclipse/,将tomcat插件解压后,把com.sysdeo.eclipse.tomcat_3.3.0文件夹放在eclipse默认路径下的/plugins路径下;

然后重启eclipse,即可看到有tomcat图标了。

配置tomcat的文章,参考:http://blog.csdn.net/njchenyi/article/details/6042760,虽然是windows的,但没有本质差别;

创建servlet,参考:http://blog.csdn.net/njchenyi/article/details/6042763

使用命令行,也可以编译servlet.

首先,将编译用的api文件拷贝到java文件同一目录下,我用的是/usr/share/java/servlet_2_4_api.jar;

然后使用javac -classpath servlet_2_4_api.jar HelloWorldExample11.java进行编译;即可生成class文件;

HelloWorldExample11.java代码如下:

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
* The simplest possible servlet.
*
* @author James Duncan Davidson
*/

public class HelloWorldExample11 extends HttpServlet {

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
ResourceBundle rb =
ResourceBundle.getBundle("LocalStrings",request.getLocale());
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head>");

String title = rb.getString("helloworld.title");

out.println("<title>" + title + "</title>");
out.println("</head>");
out.println("<body bgcolor=\"white\">");

// note that all links are created to be relative. this
// ensures that we can move the web application that this
// servlet belongs to to a different place in the url
// tree and not have any harmful side effects.

// XXX
// making these absolute till we work out the
// addition of a PathInfo issue

out.println("<a href=\"../helloworld.html\">");
out.println("<img src=\"../images/code.gif\" height=24 " +
"width=24 align=right border=0 alt=\"view code\"></a>");
out.println("<a href=\"../index.html\">");
out.println("<img src=\"../images/return.gif\" height=24 " +
"width=24 align=right border=0 alt=\"return\"></a>");
out.println("<h1>" + title + "</h1>");
out.println("</body>");
out.println("</html>");
}
}

最新文章

  1. 在 case 语句中使用字符串-转
  2. 用.NET MVC实现长轮询,与jQuery.AJAX即时双向通信
  3. 加快ArcGIS Server创建缓存速度,CachingTools的实例数
  4. ASM:《X86汇编语言-从实模式到保护模式》第12章:存储器的保护
  5. MySQL中删除重复数据的简单方法,mysql删除重复数据
  6. iOS 深拷贝和浅拷贝
  7. Python之路【第二十二篇】:Django之Model操作
  8. FFMPEG-数据结构解释(AVCodecContext,AVStream,AVFormatContext)
  9. 2015-09-22CSS:border、background、表格、超链接、overflow、firebug
  10. NOI2014 Day2
  11. Jekyll: .md to .html with self defined themes..
  12. socket端口外网无法连接解决方法
  13. 网络基础-再议TCP
  14. SharePoint 2013 页面访问,Url中间多一段&amp;quot;_layouts/15/start.aspx#&amp;quot;
  15. 交换两个局部变量Integer的值
  16. Microsoft Internet Explorer v11 / XML External EntityInjection 0day
  17. lvs dr 模型配置详解
  18. 2019.01.17 bzoj2333: [SCOI2011]棘手的操作(启发式合并)
  19. canvas设置阴影
  20. 用oradebug short_stack及strace -p分析oracle进程是否dead或出现故障

热门文章

  1. css3的2D变形
  2. PHP的垃圾回收机制(开启垃圾回收机制后的优缺点是什么)
  3. non-identifying and identifying
  4. spring源码学习之bean的加载(三)
  5. stream的map用法
  6. 用canvas 画出圆形图片
  7. Sublime setting 个性修改
  8. JavaScript数据存储和深浅拷贝实际运用
  9. js &amp;&amp;操作符解析
  10. MySQL加快批量更新 UPDATE优化