Package javax.servlet

Examples of javax.servlet.ServletContext


    private final static String LOG4J_PROPERTIES_LOCATION = "/WEB-INF/log4j.properties";

    private String configFilesLocations = "classpath*:spring/applicationContext.xml classpath*:spring/security.xml /WEB-INF/spring/applicationContext.xml";

    @Override public void contextInitialized(ServletContextEvent event) {
      ServletContext servletContext = event.getServletContext();
      initLog4J(servletContext);
        String serverInfo = servletContext.getServerInfo();
        if (logger.isInfoEnabled()) logger.info("Detected container: " + serverInfo);
        serverInfo = serverInfo.toUpperCase();
        String server = serverInfo.indexOf("TOMCAT") >= 0 ? "tomcat" : "jetty";
        if ((serverInfo.indexOf("SUN JAVA") >= 0) | (serverInfo.indexOf("GLASSFISH") >= 0)) server = "glassfish";
        configFilesLocations = configFilesLocations.replace(" ", " classpath*:spring/" + server + ".xml ");
View Full Code Here


     */
    protected void applyDecoratorUsingJSP(Page page, Decorator decorator, HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            request.setAttribute(PAGE, page);
            ServletContext context = getServletContext();
            // see if the URI path (webapp) is set
            if (decorator.getURIPath() != null) {
                // in a security conscious environment, the servlet container
                // may return null for a given URL
                if (context.getContext(decorator.getURIPath()) != null) {
                    context = context.getContext(decorator.getURIPath());
                }
            }
            // get the dispatcher for the decorator
            RequestDispatcher dispatcher = context.getRequestDispatcher(decorator.getPage());
            // create a wrapper around the response
            dispatcher.include(request, response);

            // set the headers specified as decorator init params
            while (decorator.getInitParameterNames().hasNext()) {
View Full Code Here

    protected SessionFactory lookupSessionFactory() {
        if (logger.isDebugEnabled())
            logger.debug("Using session factory '" + getSessionFactoryBeanName() + "' for OpenSessionInViewFilter");

        ServletConfig sc = PortletContext.getContext().getServletConfig();
        ServletContext servletContext = null;
       
        if (sc != null) {
            ServletActionContext.setServletConfig(sc);
            servletContext = ServletActionContext.getServletContext();
        }else {
View Full Code Here

        try {

            ///////////////////////////For OpenSessionInXWorkInterceptor in WebWork Interceptor/////////////////////
            if (Container.get() == Container.TOMCAT) {
                javax.servlet.http.HttpServletRequestWrapper requestWrapper = (javax.servlet.http.HttpServletRequestWrapper) request;
                ServletContext servletContext = requestWrapper.getSession().getServletContext();
                PortletContext.getContext().setServletContext(servletContext);
            } else {
                PortletContext.getContext().setServletConfig(((PortletConfigImpl) getPortletConfig()).getServletConfig());
            }
View Full Code Here

        doAssertions(xfire);
    }
      
    public void testConfigLoaderWithParentContext() throws Exception
    {
      ServletContext servletCtx = new MockServletContext();
      ClassPathXmlApplicationContext appCtx = new ClassPathXmlApplicationContext(new String[] {"org/codehaus/xfire/spring/xfire.xml"});

        XFireConfigLoader configLoader = new XFireConfigLoader();
        XFire xfire = configLoader.loadConfig("META-INF/xfire/sservices.xml", appCtx);
View Full Code Here

        if ( info )
        {
            __log.info( "Initializing" );
        }

        ServletContext ctx = servletConfig.getServletContext(  );

        /* Initializing the ServiceFactory */
        in = ctx.getResourceAsStream( SERVICE_DD );

        if ( in == null )
        {
            throw new PortletException( "Resource not found: " + SERVICE_DD );
        }

        _serviceFactory = new PortletServiceFactoryImpl( this );
        _serviceFactory.init( in, servletConfig );

        /* Initialize the portlets */
        in = ctx.getResourceAsStream( PORTLET_DD );

        if ( in == null )
        {
            throw new PortletException( "Resource not found: " + PORTLET_DD );
        }
View Full Code Here

    return sortMap(result);
  }
 
  private Map<String, String> getContainerServletInfo(HttpServletRequest aRequest){
    Map<String, String> result = new LinkedHashMap<String, String>();
    ServletContext context = getContext(aRequest);
    result.put("Host Name", aRequest.getServerName());
    result.put("Operating System", System.getProperty("os.arch") + " " +  System.getProperty("os.name") + " " + System.getProperty("os.version"));
    result.put("Container", context.getServerInfo());
    result.put("Controller Name", context.getClass().getName());
    result.put("Home URL", getHome(aRequest));
    return result;
  }
View Full Code Here

   <P>Some jars will not have a value for <tt>Specification-Version</tt>. These will be
   reported as {@link #UNSPECIFIED}.
  */ 
  private Map<String, String> getJarVersions(HttpServletRequest aRequest){
    Map<String, String> result = new HashMap<String, String>();
    ServletContext context = getContext(aRequest);
    Set paths = context.getResourcePaths("/WEB-INF/lib/");
    fLogger.fine(paths.toString());
    Iterator iter = paths.iterator();
    while ( iter.hasNext() ) {
      String jarFileName = iter.next().toString();
      JarInputStream jarStream = null;
      try {
        jarStream = new JarInputStream(context.getResourceAsStream(jarFileName));
      }
      catch (IOException ex){
        fLogger.severe("Cannot open jar file (to fetch Specification-Version from the jar Manifest).");
      }
      result.put(jarFileName, fetchSpecNamesAndVersions(jarStream));
View Full Code Here

      "/de/odysseus/calyxo/control/calyxo-control-config-empty.xml"
    );
    TestServletConfig config = new TestServletConfig("test", params);
    ControlModuleMapping mapping = new ControlModuleMapping("/test/*");

    ServletContext context = config.getServletContext();
    ControlModuleGroup group = ControlModuleGroup.getInstance(context);
    ControlModuleContext module = new ControlModuleContext(config, mapping, null);
    assertTrue(group.isEmpty());
    group.add(module);
    assertFalse(group.isEmpty());
View Full Code Here

  }

  protected void setUp() throws ServletException {
    request = new TestRequest();
    // configure module support
    ServletContext context = request.getSession().getServletContext();
    TestModuleGroup group = TestModuleGroup.getInstance(context);
    // configure test modules
    module1 = new TestModuleContext("module1", context);
    module2 = new TestModuleContext("module2", context);
    group.add(module1);
View Full Code Here

TOP

Related Classes of javax.servlet.ServletContext

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.