Jetty嵌入式的支持jsp的web container,我在一个港股行情系统里嵌入了jetty来通过http监控系统状况。

Jetty的pom依赖库

<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
<version>6.1.19</version>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-compiler</artifactId>
<version>5.5.12</version>
</dependency>
<dependency>
<groupId>tomcat</groupId>
<artifactId>jasper-runtime</artifactId>
<version>5.5.12</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>

jetty没有自己的compiler,所以需要依赖tomcat的jar。同时它需要ant的compiler,否则会报错:

java.lang.IllegalStateException: No Java compiler available
at org.apache.jasper.JspCompilationContext.createCompiler(JspCompilationContext.java:224)...

所以需要加入ant

需要tools.jar
否则会提示
Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK
at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:105)

所以把JAVA_HOME/lib/tools.jar加入到启动命令里即可,如果是在eclipse或者其他的IDE里启动,把tools.jar加到JRE的lib里。

启动代码
public void run()
{
try {
server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(this.getPort());
server.addConnector(connector);

ContextHandlerCollection contexts = new ContextHandlerCollection();
server.setHandler(contexts);
WebAppContext webapp = new WebAppContext();
webapp.setDefaultsDescriptor(getDescriptor());
webapp.setResourceBase(getResourceBase());
webapp.setContextPath(getContextPath());
contexts.addHandler(webapp);

/** 启动 */
server.start();
System.out.println("Monitor Server listening on : " + this.getPort());
server.join();
} catch (Exception e) {
e.printStackTrace();
}
}

搜索更多相关主题的帖子: Linux Jsp Jetty

  • 提供Oracle管理/故障处理/优化/安装/RAC/备份恢复技术服务,提供专业的Oracle培训和咨询服务
  • 专业论坛 http://www.inthirties.com
  • 技术博客 http://blog.csdn.net/inthirties
  • 个人站点 http://blog.inthirties.com

在你的应用里使用Jetty嵌入式相关推荐

  1. Spring MVC实现Spring Security,Spring Stomp websocket Jetty嵌入式运行

    使用Spring框架各个组件实现一个在线聊天网页,当有用户连接WebSocket,服务器监听到用户连接会使用Stomp推送最新用户列表,有用户断开刷新在线列表,实时推送用户聊天信息.引入Jetty服务 ...

  2. jetty嵌入式容器_嵌入式Jetty和Apache CXF:借助Spring Security来保护REST服务

    jetty嵌入式容器 最近,我遇到了一个非常有趣的问题,我认为这只需要几分钟就可以解决:在Linux中使用Spring Security (当前稳定版本3.2.5 )保护Apache CXF (当前版 ...

  3. 怎么在html表格里加入图片不显示不出来,WPS表格里插入的嵌入式图片在Office的Excel无法正常显示...

    WPS表格里插入的嵌入式图片 是=DISPIMG格式,这个图片是wps特有的功能,它不是shape, 有shapes集合中找不到.只能用wps的et表格打开才能看到这个图片 在Excel中打开会显示为 ...

  4. Jetty篇教程 之Jetty 嵌入式服务器

    1.Jetty简介 1.1 什么是Jetty Jetty是一个提供 HTP服务器.HTTP客户端和javax.servlet容器的开源项目. Jetty9 是Jetty的最近一个版本且比之前的版本有很 ...

  5. c语言里变量列表,嵌入式C语言里的土豪们之变量类型

    嵌入式C语言里的土豪们之变量类型本文引用地址:http://www.eepw.com.cn/article/184332.htm 上一篇我们谈到了运算奢华大户除法(详见<嵌入式C语言里的土豪们之 ...

  6. Spring MVC+Stomp+Security+H2 Jetty

    #### 这一个什么项目 ##### 使用技术 Spring MVC Spring Security Spring webflux Spring stomp Jetty 嵌入式运行 H2 嵌入式数据库 ...

  7. Google 选择 Jetty 放弃 Tomcat

    [IT168 资讯]Google 应用系统引擎最初是以 Apache Tomcat 作为其 webserver/servlet 容器的,但最终将切换到 Jetty 上. 这个决定让许多开发人员都诧异的 ...

  8. (转)Google 选择 Jetty, 放弃 Tomcat

    Google 选择 Jetty, 放弃 Tomcat 10 小时前 by 见习记者 乡村里的一条土狗 评论(4) 有830人浏览 收藏 声明:JavaEye新闻文章的版权属于JavaEye网站所有,严 ...

  9. Jetty是什么?Jetty介绍以及配置

    转载自:http://jiajunde.javaeye.com/blog/373262 Jetty是什么 Jetty项目简介 Jetty是一个开源.基于标准.全功能实现的Java服务器.它在Apach ...

最新文章

  1. Git fetch和git pull的区别
  2. 异步爬虫框架与协程浅析
  3. JavaScript 操作 Cookie
  4. SQL Server中把查询出来的结果重新编号作为一列
  5. Introduction or Why Should I Bother
  6. 创建一个简单的WCF程序
  7. STM32--MPU内存保护单元(二)
  8. 数学建模-14.主成分分析PCA
  9. ArrayList 练习
  10. Java 2实用教程(第5版)实验指导与习题解答 第3章-上机实践-分支与循环语句
  11. MATLAB画图详细教程
  12. 【工大SCIR】基于动态图交互网络的多意图口语语言理解框架
  13. JavaWeb开发了解
  14. 简单的java实现分解质因数。
  15. 特斯拉充电电流设置多大_特斯拉充电时间
  16. DCCA互相关系数 理论
  17. Java-Collection的子接口-List集合
  18. Android进阶(二十六)MenuInflater实现菜单添加
  19. vue中打开一个新页面
  20. otter学习 | otter_manager 安装配置

热门文章

  1. 指令系统由计算机组成决定,《计算机组成原理》第5章指令系统.ppt
  2. python+itchat实现微信远程控制电脑
  3. 玩转python(一)——微信远程控制电脑
  4. kux格式怎么转换mp4,这里有妙招
  5. html5 文字转换烟花,用HTML5制作烟火效果的教程
  6. 高中数学基础-对数2.2.2对数函数图象及其性质(上)
  7. 哪些是性价比高的骨传导蓝牙耳机,五款骨传导蓝牙耳机推荐
  8. 每日积累【Day 3】Hbase架构深入学习
  9. 聊聊你不知道的Java变量转型
  10. 华为mate30pro和华为p40pro有什么区别