标签: embedded-jetty

无法在嵌入式Jetty服务器中加载JSTL taglib

我正在编写一个在嵌入式Jetty实例中运行的Web应用程序.

当我尝试执行JSTL语句时,收到以下异常:

org.apache.jasper.JasperException:/index.jsp(1,63)PWC6188:绝对uri:http://java.sun.com/jsp/jstl/core无法在web.xml或jar文件中解析使用此应用程序部署

我在classpath上有以下jar

  • ANT-1.6.5.jar
  • ANT-1.7.1.jar
  • 蚂蚁发射-1.7.1.jar
  • 核心3.1.1.jar
  • 码头,6.1.22.jar
  • 码头-UTIL-6.1.22.jar
  • JSP的2.1-6.1.14.jar
  • JSP-API-2.1.jar
  • JSTL-1.2.jar
  • servlet的API-2.5-20081211.jar
  • servlet的API-2.5-6.1.14.jar
  • 标准1.1.2.jar

我的web.xml看起来像这样:

<?xml version="1.0" encoding="ISO-8859-1"?>  
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"  
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee h77p://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"  
    version="2.4">  
    <display-name>test</display-name>  
</web-app>
Run Code Online (Sandbox Code Playgroud)

我的代码看起来像这样:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>  
<html>  
    <body>  
        <h2>Hello World!</h2>  
        <%= new java.util.Date() %><br/>  
        ${1+2}<br/>  
        <c:out var="${5+9}"/><br/>  
    </body>  
</html>
Run Code Online (Sandbox Code Playgroud)

我开始使用这样的嵌入式Jetty服务器:

Server server = new Server(80);  
WebAppContext context = new WebAppContext("pig-1.0-SNAPSHOT.war","/");
server.addHandler(context);
server.start();
Run Code Online (Sandbox Code Playgroud)

我花了两天时间尝试各种jar文件组合,web.xml配置和标签库声明,但无济于事.

如何在完整的JSTL支持下启动并运行嵌入式Jetty服务器?

java jstl jetty taglib embedded-jetty

15
推荐指数
3
解决办法
2万
查看次数

如何为java junit测试运行jetty服务器

我正在尝试编写集成测试以在本地启动jetty服务器,然后使用客户端与其余URI进行通信并调用下游的业务逻辑.但是,当我启动我的jetty服务器时,它不会放弃控件,因此我的客户端不会被执行.所以我使用线程在不同的线程中启动我的码头,但是,线程在客户端调用之前完成,它表示连接被拒绝.我可以采取任何方法吗?

@Test
public void testPerform() {

    final JettyServer jettyServer = JettyServer.create();
    jettyServer.buildJettyServer(ServletContextHandler.SESSIONS, "/", 8080, TestResource.class);

    Runnable runnable = new Runnable()
    {
        @Override
        public void run()
        {
            jettyServer.start();
        }
    };

    new Thread(runnable).start();

    final javax.ws.rs.client.Client client = ClientBuilder.newClient();

    final Response response = client.target("http://localhost:8080/test").request().post(Entity.text(""));

    jettyServer.stop();
}
Run Code Online (Sandbox Code Playgroud)

java rest jetty embedded-jetty

15
推荐指数
1
解决办法
2万
查看次数

缺少Jetty中的JSP支持,或者令人困惑的日志消息?

通过调用6.1.24中的API启动jetty.

JSP 2.1组件位于类路径中.

org.mortbay.jetty:jsp-2.1-jetty:jar:6.1.24:compile
Run Code Online (Sandbox Code Playgroud)

但日志说:

2010-08-19 08:16:19.443:INFO::NO JSP Support for /basis_ws, did not find org.apache.jasper.servlet.JspServlet
Run Code Online (Sandbox Code Playgroud)

使用相应的maven-jetty-plugin时,我没有看到此消息.

我错过了什么?

jsp embedded-jetty

14
推荐指数
2
解决办法
3万
查看次数

在SBT 0.10中指定Jetty端口

我需要运行在端口的缺省值8080不同的嵌入式码头,使用SBT 0.10的问题在这里回答为SBT 0.7 - 在该文件中,我需要添加替代的码头港口运行在开发模式提升Web应用程序时SBT?.我找不到对SBT 0.10做同样的参考我对多模块使用完全配置(Build.scala)而不是快速sbt dsl.

scala jetty embedded-jetty sbt

14
推荐指数
2
解决办法
3539
查看次数

如何使用嵌入式Jetty 9成功解析JSTL URI?

我正在打包一个Web应用程序存档(.war),以便可以通过java -jar webapp.war在主类中使用此代码启动Jetty 9的嵌入式副本来启动它:

int port = Integer.parseInt(System.getProperty("port", "80")); // I know this has implications :)
String contextPath = System.getProperty("contextPath", "");
Server server = new Server(port);
ProtectionDomain domain = Deployer.class.getProtectionDomain();
URL location = domain.getCodeSource().getLocation();
WebAppContext webapp = new WebAppContext();
webapp.setContextPath("/" + contextPath);
webapp.setWar(location.toExternalForm());
server.setHandler(webapp);
server.start();
server.join();
Run Code Online (Sandbox Code Playgroud)

但是,当第一个包含JSTL taglib声明的JSP被编译时,我遇到了这个错误:

org.apache.jasper.JasperException: /WEB-INF/html/user/login.jsp(2,62) PWC6188: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:92)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:378)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:172)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:431)
at …
Run Code Online (Sandbox Code Playgroud)

jsp jstl jetty embedded-jetty

14
推荐指数
2
解决办法
2万
查看次数

从嵌入式Jetty中的备用路径提供静态文件

我正在尝试创建一个嵌入式jetty服务器,其中包含一个服务于某些动态数据的自定义servlet,以及将为某些图像提供服务的默认servlet.我有自定义servlet工作,但我无法弄清楚如何添加默认servlet来提供图像文件.

这就是我所拥有的......

private void setUpServer(ServerOptions options){
    s = new Server(options.getPort());
    this.options = options;
    context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    s.setHandler(context);
    context.addServlet(new ServletHolder(new DataServlet()), "/data/*");
    context.addServlet(new ServletHolder(new DefaultServlet()), "/pictures/*");
}
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何配置DefaultServlet作为文件服务器,仍然有自定义DataServelet仍然工作.

有没有人有任何想法?

java servlets jetty fileserver embedded-jetty

14
推荐指数
1
解决办法
2万
查看次数

嵌入式vs独立Tomcat(HTTP)服务器

我正在开发一个新项目,它将是一个带有前端UI和后端Web服务的Web应用程序.我开始研究像Tomcat/Jetty那样使用哪些服务器......我还注意到这些HTTP服务器有一个嵌入式版本.我不明白何时对独立版本使用嵌入式版本.我尝试使用谷歌搜索,但无法找到令人信服的答案,所以如果有人向我解释嵌入式服务器的用例,我将不胜感激.提前致谢.

tomcat jetty embedded-jetty httpserver embedded-tomcat-7

14
推荐指数
2
解决办法
1万
查看次数

Spark Web框架记录请求和响应

我正在使用Spark Web框架来开发REST API.有没有办法自动记录所有传入的请求和传出的响应(查询参数,标题,状态代码等)或我是否需要为每个处理程序手动添加日志记录?

Spark文档中没有关于此主题的内容.

谢谢.

java logging jetty embedded-jetty

14
推荐指数
1
解决办法
2418
查看次数

如何将i-jetty服务器嵌入到Android应用程序中?

嗨:我想将i-jetty集成到Android应用程序中,而不是相反.有没有人包括i-jetty之前让它在Android 2.1或2.2下运行?

java android jetty embedded-jetty ijetty

13
推荐指数
1
解决办法
5083
查看次数

向jetty添加多个资源目录

希望在Jetty中使用多个静态目录.服务器运行时:

  http://localhost:8282/A
  http://localhost:8282/B 
  http://localhost:8282/C
Run Code Online (Sandbox Code Playgroud)
  • A放在X/V/A中
  • B放在Q/Z/B中
  • C放在P/T/C中

以下失败:

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setWelcomeFiles(new String[]{"index.html"});
    resource_handler.setResourceBase(HTML_SITE);

    ResourceHandler resource_handler1 = new ResourceHandler();
    resource_handler1.setWelcomeFiles(new String[]{"index.html"});
    resource_handler1.setResourceBase(HTML_CLIENTZONE_SITE);

    // deploy engine
    WebAppContext webapp = new WebAppContext();

    String dir = System.getProperty("user.dir");
    webapp.setResourceBase(getWebAppPath());
    webapp.setContextPath("/");


     HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler,resource_handler1 ,webapp,  new DefaultHandler()});
    server.setHandler(handlers);
Run Code Online (Sandbox Code Playgroud)

如何添加多个静态资源目录?

directory jetty embedded-jetty

13
推荐指数
1
解决办法
6556
查看次数