Package org.apache.tomcat.core

Examples of org.apache.tomcat.core.Context


  return context;
    }

    // -------------------- Public facade methods --------------------
    public ServletContext getContext(String path) {
        Context target=contextM.getContext(context, path);
  return (ServletContext)target.getFacade();
    }
View Full Code Here


  sendError(sc, "No detailed message");
    }

    public void sendError(int sc, String msg) throws IOException {
  if (isCommitted()) {
      Context ctx=response.getRequest().getContext();
      ctx.log( "Servlet API error: sendError with commited buffer ", new Throwable("Trace"));
      throw new IllegalStateException(sm.
              getString("hsrf.error.ise"));
  }

  //   if (sc != HttpServletResponse.SC_UNAUTHORIZED)  // CRM: FIXME
View Full Code Here

      if( dep!=null && ! dep.isExpired() ) {
    // if the jspfile is older than the class - we're ok
    return 0;
      }

      Context ctx=req.getContext();
     
      // Mangle the names - expensive operation, but nothing
      // compared with a compilation :-)
      JasperMangler mangler=
    new JasperMangler(ctx.getWorkDir().getAbsolutePath(),
             ctx.getAbsolutePath(),
             jspFile );


            // If unsafe path or JSP file doesn't exist, return "not found"
            // Avoids creating work directories for non-existent JSP files
            String path=mangler.getJspFilePath();
            if( path == null )
                return 404;
            File f = new File( path );
            if( !f.exists() )
                return 404;
      // register the handler as dependent on the jspfile
      if( dep==null ) {
    dep=setDependency( ctx, mangler, handler );
                // if dep is null then path is unsafe, return "not found"
                if( dep == null ) {
                    return 404;
                }
               
    // update the servlet class name
    handler.setServletClassName( mangler.getServletClassName() );

    // check again - maybe we just found a compiled class from
    // a previous run
    if( ! dep.isExpired() )
        return 0;
      }

      //      if( debug > 3)
      ctx.log( "Compiling: " + jspFile + " to " +
         mangler.getServletClassName());
     
      //XXX old servlet -  destroy();
     
      // jump version number - the file needs to be recompiled
      // reset the handler error, un-initialize the servlet
      handler.setErrorException( null );
      handler.setState( Handler.STATE_ADDED );
     
      // Move to the next class name
      mangler.nextVersion();

      // record time of attempted translate-and-compile
      // if the compilation fails, we'll not try again
      // until the jsp file changes
      dep.setLastModified( System.currentTimeMillis() );

      // Update the class name in wrapper
      if( debug> 1 )
    log.log( "Update class Name " + mangler.getServletClassName());
      handler.setServletClassName( mangler.getServletClassName() );

      // May be called from include, we need to set the context class
            // loader
      // for jaxp1.1 to work using the container class loader
            //Extra test/warnings for tools.jar

            ClassLoader savedContextCL= containerCCL( ctx.getContextManager()
                                                  .getContainerLoader() );

            if( useWebAppCL ) {
                try {
                    ctx.getClassLoader().loadClass( "sun.tools.javac.Main" );
                    if(debug>0) log.log( "Found javac using context loader");
                } catch( ClassNotFoundException ex ) {
                    if(debug>0) log.log( "javac not found using context loader");
                }

                try {
                    ctx.getContextManager().getContainerLoader().
                        loadClass( "sun.tools.javac.Main" );
                    if( debug > 0 )
                        log.log( "Found javac using container loader");
                } catch( ClassNotFoundException ex ) {
                    if( debug > 0 )
                        log.log( "javac not found using container loader");
                }
            }

      try {
    Options options=new JasperOptionsImpl(args);
    JspCompilationContext ctxt=createCompilationContext(req,
                    jspFile,
                    options,
                    mangler);
    jsp2java( mangler, ctxt );

    javac( req, options, ctxt, mangler );
     
    if(debug>0)log.log( "Generated " +
            mangler.getClassFileName() );
            } catch ( java.io.FileNotFoundException fnfex ){
    containerCCL( savedContextCL );
    return 404;
      } catch( Exception ex ) {
    if( ctx!=null )
        ctx.log("compile error: req="+req, ex);
    else
        log.log("compile error: req="+req, ex);
    handler.setErrorException(ex);
    handler.setState(Handler.STATE_DISABLED);
    // until the jsp cahnges, when it'll be enabled again
View Full Code Here

      xh.addRule("web-app/servlet", new XmlAction() {
         public void end( SaxContext xctx)
             throws Exception {
             ServletInfo sw=(ServletInfo)
           xctx.currentObject();
             Context cctx=(Context)xctx.previousObject();
             sw.addServlet(cctx, wxr);
         }
           }
       );
      // remove it from stack when done
View Full Code Here

    }
    public void end( SaxContext ctx) throws Exception {
  Stack st=ctx.getObjectStack();
  String tag=ctx.getTag(ctx.getTagCount()-1);
  SecurityConstraint sc=(SecurityConstraint)st.pop();
  Context context=(Context)st.peek();

  st.push( sc ); // restore stack
  // add all patterns that will need security

  String roles[]=sc.getRoles();
  String transport=sc.getTransport();
  Enumeration en=sc.getResourceCollections();
  while( en.hasMoreElements()) {
      ResourceCollection rc=(ResourceCollection)en.nextElement();
      String paths[]=rc.getPatterns();
      String meths[]=rc.getMethods();
      context.addSecurityConstraintpaths, meths ,
              roles, transport);
  }
    }
View Full Code Here

  return s;
    }

    public String addContext() {
  if ((addContextPath != null) && (addContextDocBase != null)) {
            Context context = new Context();
            context.setContextManager(cm);
            context.setPath(addContextPath);
            context.setDocBase(addContextDocBase);

      try {
                cm.addContext(context);
                cm.initContext(context);
      }
View Full Code Here

  return s;
    }

    public String addContext() {
  if ((addContextPath != null) && (addContextDocBase != null)) {
            Context context = new Context();
            context.setContextManager(cm);
            context.setPath(addContextPath);
            context.setDocBase(addContextDocBase);

      try {
                cm.addContext(context);
                cm.initContext(context);
      }
View Full Code Here

TOP

Related Classes of org.apache.tomcat.core.Context

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.