Configuring Jetty JSP support in embedded mode in Maven project

前端 未结 6 1452
遥遥无期
遥遥无期 2021-01-30 05:50

I can visit .html pages with Jetty, but when I visit a .jsp page I get:

0 13:21:13 / [INFO] No JSP support. Check that JSP jars are in lib/jsp and th

6条回答
  •  一生所求
    2021-01-30 06:09

    I know this has been answered a while ago. I could not get the answer from Ben McCann to work for me. However, i had luck by adding JSP support directly to Jetty by adding

        
        
            org.mortbay.jetty
            jsp-2.1
            6.1.14
            jar
        
        
            org.mortbay.jetty
            jsp-api-2.1
            6.1.14
            jar
        
    

    Strangely, this was not supported by the version 6.1.24 I originally had.

    So in total, that made my pom.xml look like this:

    http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

    wikiproject
    wikiproject
    1.0-SNAPSHOT
    
    
        6.1.14
    
    
    
    
    
        
            org.mortbay.jetty
            jetty
            ${jetty.version}
            jar
        
    
        
            org.mortbay.jetty
            jetty-util
            ${jetty.version}
            jar
        
    
        
            org.mortbay.jetty
            jetty-plus
            ${jetty.version}
            jar
        
    
        
        
            org.mortbay.jetty
            jsp-2.1
            ${jetty.version}
            jar
        
        
            org.mortbay.jetty
            jsp-api-2.1
            ${jetty.version}
            jar
        
    
        
            org.apache.ant
            ant-antlr
            1.7.1
        
    
    
    

    and my start class (which i added in folder \src\test\java\com\company\wikiproject )

    package com.company.wikiproject;
    import org.mortbay.jetty.Connector;
    import org.mortbay.jetty.Server;
    import org.mortbay.jetty.bio.SocketConnector;
    import org.mortbay.jetty.webapp.WebAppContext;
    /**  
     * User: Jesper Rønn-Jensen  
     * start wiki pages  
     */
    

    public class Start {

    public static void main(String[] args) {
        Server jettyServer = null;
        try {
            jettyServer = new Server();
    
            SocketConnector conn = new SocketConnector();
            conn.setPort(8080);
            jettyServer.setConnectors(new Connector[]{conn});
    
            WebAppContext context = new WebAppContext();
            context.setContextPath("/");
            context.setWar("src/main/webapp");
    
            jettyServer.setHandler(context);
            jettyServer.start();
        } catch (Exception ignore) {
            if (jettyServer != null) {
                try {
                    jettyServer.stop();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    

    }

提交回复
热议问题