当前位置: 首页>>代码示例>>Java>>正文


Java JspServlet类代码示例

本文整理汇总了Java中org.apache.jasper.servlet.JspServlet的典型用法代码示例。如果您正苦于以下问题:Java JspServlet类的具体用法?Java JspServlet怎么用?Java JspServlet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JspServlet类属于org.apache.jasper.servlet包,在下文中一共展示了JspServlet类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpHttpServer

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
private void setUpHttpServer() throws Exception {
    server = new HttpServer();
    SocketListener listener = new SocketListener();
    listener.setPort(configuration.getPort());
    server.addListener(listener);

    ServletHttpContext servletContext = new ServletHttpContext();
    servletContext.setContextPath("jsunit");
    servletContext.setResourceBase(configuration.getResourceBase().toString());

    servletContext.addServlet("JSP", "*.jsp", JspServlet.class.getName());
    servletContext.addHandler(new ResourceHandler());

    ConfigurationManager.clearConfigurationProviders();
    ConfigurationManager.addConfigurationProvider(new XmlConfigurationProvider(xworkXmlName()));
    com.opensymphony.webwork.config.Configuration.set("webwork.action.extension", "");

    for (String servletName : servletNames())
        addWebworkServlet(servletContext, servletName);
    server.addContext(servletContext);

    if (Monitor.activeCount() == 0)
        Monitor.monitor();
}
 
开发者ID:BradNeuberg,项目名称:purple-include,代码行数:25,代码来源:AbstractJsUnitServer.java

示例2: start

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
public void start() {

        final int port   = ConfigurationManager.getConfigInstance().getInt(RSSConstants.JETTY_HTTP_PORT, Integer.MIN_VALUE);

        final Context context = new Context(jettyServer, "/", Context.SESSIONS);
        context.setResourceBase(RSSConstants.WEBAPPS_DIR);
        context.setClassLoader(Thread.currentThread().getContextClassLoader());
        context.addServlet(JspServlet.class, "*.jsp");

        // Enable hystrix.stream
        context.addServlet(HystrixMetricsStreamServlet.class, RSSConstants.HYSTRIX_STREAM_PATH);

        final Server server = new Server(port);
        server.setHandler(context);

        try {
            karyonServer.start();
            server.start();
        } catch (Exception exc) {
            throw new RuntimeException("Cannot start karyon server ...", exc);
        }
    }
 
开发者ID:Netflix,项目名称:recipes-rss,代码行数:23,代码来源:BaseJettyServer.java

示例3: executeApp

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
@Override
public void executeApp() throws Exception {
    int port = getAvailablePort();
    Tomcat tomcat = new Tomcat();
    tomcat.setBaseDir("target/tomcat");
    tomcat.setPort(port);
    Context context =
            tomcat.addContext("", new File("src/test/resources").getAbsolutePath());

    WebappLoader webappLoader = new WebappLoader(RenderJspInTomcat.class.getClassLoader());
    context.setLoader(webappLoader);

    Tomcat.addServlet(context, "hello", new ForwardingServlet());
    context.addServletMapping("/hello", "hello");
    Tomcat.addServlet(context, "jsp", new JspServlet());
    context.addServletMapping("*.jsp", "jsp");

    tomcat.start();
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    int statusCode = asyncHttpClient.prepareGet("http://localhost:" + port + "/hello")
            .execute().get().getStatusCode();
    asyncHttpClient.close();
    if (statusCode != 200) {
        throw new IllegalStateException("Unexpected status code: " + statusCode);
    }
    tomcat.stop();
    tomcat.destroy();
}
 
开发者ID:glowroot,项目名称:glowroot,代码行数:29,代码来源:JspRenderIT.java

示例4: EmbeddedJspServer

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
public EmbeddedJspServer( Integer port, String webappFolder ) {
    if (port == null) {
        port = 8080;
    }
    _server = new Server(port);
    try {

        ServletHandler servletHandler = new ServletHandler();
        _server.setHandler(servletHandler);

        configureServletHandler(servletHandler);

        // add jsp servlet mappings
        String[] jspExtensions = {"*.jsp", "*.jspf", "*.jspx", "*.xsp", "*.JSP", "*.JSPF", "*.JSPX", "*.XSP"};
        Class<JspServlet> jspServletClass = org.apache.jasper.servlet.JspServlet.class;
        for( String jspExt : jspExtensions ) {
            ServletHolder servletHolder = servletHandler.addServletWithMapping(jspServletClass, jspExt);
            servletHolder.setInitParameter("logVerbosityLevel", "INFO");
            servletHolder.setInitParameter("fork", "false");
            servletHolder.setInitParameter("keepgenerated", "true");
            // servletHolder.setInitParameter("keepgenerated", "true");
            // <load-on-startup>0</load-on-startup>
        }

        if (webappFolder != null) {
            webapp = getWebAppContext(_server, webappFolder);
            configureWebAppContext(webapp);
            _server.setHandler(webapp);
        }

    } catch (Exception e) {
        e.printStackTrace();
        LOG.log(Level.ALL, "Error", e);
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:36,代码来源:EmbeddedJspServer.java

示例5: setUp

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
@Before
public void setUp() {
    tester.setResourceBase("./src/main/webapp/jsp");
    tester.addServlet(JspServlet.class, "*.jsp");
    tester.addServlet(textInput.class, "/servlet/*");
    try {
        tester.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
    AbstractTaintUtil.setThrowException(false);
}
 
开发者ID:vdbaan,项目名称:SecuRT,代码行数:13,代码来源:WebTest.java

示例6: bind

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
/**
 * A bind method for setting up the web location to use for JSP servlets and static files.
 * Only one bind can be performed at this time.
 * @param theDiskBase the location on disk, relative to the starting directory, where to find files from
 * @param theWebBase the location in the URL, relative to the service location, where the system will service from
 */
public void bind( String theDiskBase, Map<String,String> theInitParameters ) {
	Preconditions.checkState( !didBind, "Cannot bind a web location to interface '%s' because a location was already bound.", this.getName() );
   	Preconditions.checkState( this.getState() == ExecutionLifecycleState.CREATED || this.getState() == ExecutionLifecycleState.STARTING, "Cannot bind a web location to interface '%s' while it is in the '%s' state.", this.getName(), this.getState( ) );
	Preconditions.checkArgument( !Strings.isNullOrEmpty( theDiskBase ), String.format( "Website interface '%s' needs a disk location.", getName( ) ) );
	
	// information on parameters can be found here: http://wiki.eclipse.org/Jetty/Howto/Configure_JSP
	// setup our resources and base class loader
	this.getServletContext().setResourceBase( theDiskBase );
	this.getServletContext().setClassLoader( Thread.currentThread().getContextClassLoader());

	logger.info( "Binding web location on interface '{}' from path '{}' to http path '{}'.", this.getName(), theDiskBase, this.getServletContext().getContextPath( ) );
	
	String webBase = "/";
	
	// first we setup the default contract/servlet for handling regular static images and files
	Servlet defaultServlet = new DefaultServlet();
       HttpContract defaultContract = new HttpServletContract( getName( ) + "_web_default", "The default servlet for handling non-JSP files", new String[] { "20130201" }, defaultServlet, webBase );
   	this.getContractManager( ).register( defaultContract );
	ContractServletHolder defaultHolder = new LaxContractServletHolder( defaultContract, defaultServlet, this );
	this.getServletContext().addServlet( defaultHolder, "/" );
	
   	
	// next we setup the jsp contract/servlet for handling jsp files
	JspServlet jspServlet = new JspServlet();
       HttpContract jspContract = new HttpServletContract( getName( ) + "_web_jsp", "The jsp servlet for handling JSP files", new String[] { "20130201" }, jspServlet, webBase );
   	this.getContractManager( ).register( jspContract );
	ContractServletHolder jspHolder = new LaxContractServletHolder( jspContract, jspServlet, this );
	this.getServletContext().addServlet( jspHolder, "*.jsp" ); // TODO: this should be relative somehow


	// we need to set up the init parameters, and will
	// treat the class path specially, since we need it
	boolean foundClasspath = false;
	
	if( theInitParameters != null ) {
		for( String name: theInitParameters.keySet( ) ) {
			jspHolder.setInitParameter( name, theInitParameters.get( name ) );
			if( String.CASE_INSENSITIVE_ORDER.compare( name, "classpath" ) == 0 ) {
				foundClasspath = true;
			}
		}
	}
	// if we don't have a class path set then we need to set it
	if( !foundClasspath ) {
		jspHolder.setInitParameter( "classpath", this.getServletContext( ).getClassPath( ) );
	}
}
 
开发者ID:Talvish,项目名称:Tales,代码行数:54,代码来源:WebsiteInterface.java

示例7: createHandlers

import org.apache.jasper.servlet.JspServlet; //导入依赖的package包/类
private HandlerCollection createHandlers() throws IOException, URISyntaxException {
    webAppContext = new WebAppContext();
    webAppContext.setParentLoaderPriority(true);
    webAppContext.setContextPath(contextPath);
    webAppContext.setResourceBase(resourceBaseDirectory.getAbsolutePath());

    File tempDir = new File(System.getProperty("java.io.tmpdir"));
    File scratchDir = new File(tempDir.toString(), "embedded-jetty-jsp");

    if (!scratchDir.exists()) {
        if (!scratchDir.mkdirs()) {
            throw new IOException("Unable to create scratch directory: " + scratchDir);
        }
    }

    System.setProperty("org.apache.jasper.compiler.disablejsr199", "false");
    ClassLoader jspClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
    webAppContext.setClassLoader(jspClassLoader);

    ServletHolder holderJsp = new ServletHolder("jsp", JspServlet.class);
    holderJsp.setInitOrder(0);
    holderJsp.setInitParameter("logVerbosityLevel", "DEBUG");
    holderJsp.setInitParameter("fork", "false");
    holderJsp.setInitParameter("xpoweredBy", "false");
    holderJsp.setInitParameter("compilerTargetVM", "1.7");
    holderJsp.setInitParameter("compilerSourceVM", "1.7");
    holderJsp.setInitParameter("keepgenerated", "true");
    webAppContext.addServlet(holderJsp, "*.jsp");
    webAppContext.addServlet(holderJsp, "*.jspf");
    webAppContext.addServlet(holderJsp, "*.jspx");

    webAppContext.setAttribute("javax.servlet.context.tempdir", scratchDir);

    webAppContext.setConfigurations(new Configuration[]{
            new WebXmlConfiguration(),
            new AnnotationConfiguration() {
                @Override
                public void preConfigure(WebAppContext context) throws Exception {
                    MultiMap<String> map = new MultiMap<>();
                    map.add(WebApplicationInitializer.class.getName(), initializer.getName());
                    context.setAttribute(CLASS_INHERITANCE_MAP, map);
                    _classInheritanceHandler = new ClassInheritanceHandler(map);
                }
            }});

    List<Handler> _handlers = new ArrayList<>();

    _handlers.add(webAppContext);

    HandlerList _contexts = new HandlerList();
    _contexts.setHandlers(_handlers.toArray(new Handler[0]));

    HandlerCollection _result = new HandlerCollection();
    _result.setHandlers(new Handler[]{_contexts});

    return _result;
}
 
开发者ID:mattprovis,项目名称:uitest,代码行数:58,代码来源:WebServer.java


注:本文中的org.apache.jasper.servlet.JspServlet类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。