Jetty 8.x, 9. x cannot load jstl PWC6188, jstlpwc6188

Source: Internet
Author: User

Jetty 8.x, 9. x cannot load jstl PWC6188, jstlpwc6188

Refer:

Cannot load JSTL taglib within embedded Jetty server: http://stackoverflow.com/questions/2151075/cannot-load-jstl-taglib-within-embedded-jetty-server

How do you get embedded Jetty 9 to successfully resolve the jstl uri? : Bytes;

JSTL core labels used: http://www.cnblogs.com/lihuiyy/archive/2012/02/24/2366806.html

JSP Expression Language: http://blog.csdn.net/csuliky/article/details/2452207
Using Spring3.2 MVC with embedded jetty9: http://stackoverflow.com/questions/19169377/using-spring3-2-mvc-with-embedded-jetty9

1. Brief Introduction

<% @ Page language = "java" contentType = "text/html; charset = ISO-8859-1" pageEncoding = "ISO-8859-1" isELIgnored = "false" %>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>

The preceding exception can be solved by adding corresponding statements on the page. However, the above problems still occur when the embedded Jetty is used here.

Add the above Code before jetty starts. The problem is that Jetty cannot load the JSTL class library. This is a bug

2. Jetty dependency

<Dependency>

<GroupId> org. eclipse. jetty </groupId>

<ArtifactId> jetty-webapp </artifactId>

<Version> 9.0.7.v20131107 </version>

<Scope> test </scope>

</Dependency>

<Dependency>

<GroupId> org. eclipse. jetty </groupId>

<ArtifactId> jetty-servlet </artifactId>

<Version> 9.0.7.v20131107 </version>

<Scope> test </scope>

</Dependency>

<Dependency>

<GroupId> org. eclipse. jetty </groupId>

<ArtifactId> jetty-jsp </artifactId>

<Version> 9.0.7.v20131107 </version>

</Dependency>

3. Run the code

Public class JettyServer {

Public static void main (String [] args) throws Exception {

System. setProperty ("DWPROJECTNO", "resource ");

System. setProperty ("DWENV", "dev ");

StartJettyServer (80 ,"/");

}

/**

* Create a Jetty Server for normal running and debugging, and use src/main/webapp as the Web application directory.

*

* @ Throws Exception

*/

Public static void startJettyServer (int port, String contextPath) throws Exception {

/* Fix jetty8.x, jetty 9.x can't load jstl library */

Field f = TldScanner. class. getDeclaredField ("systemUris ");

F. setAccessible (true );

(Set <?>) F. get (null). clear ();

F. setAccessible (false );

Server server = new Server (port );

WebAppContext webContext = new WebAppContext ("src/main/webapp", contextPath );

WebContext. setClassLoader (Thread. currentThread (). getContextClassLoader ());

WebContext. setDefaultsDescriptor ("src/test/resources/jetty-webdefault.xml ");

Server. setHandler (webContext );

Server. setStopAtShutdown (true );

Server. start ();

Server. join ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.