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