congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
IWebContext.getServletContext
Code IndexAdd Tabnine to your IDE (free)

How to use
getServletContext
method
in
org.thymeleaf.context.IWebContext

Best Java code snippets using org.thymeleaf.context.IWebContext.getServletContext (Showing top 20 results out of 315)

origin: thymeleaf/thymeleaf

return ((IWebContext) context).getServletContext();
origin: thymeleaf/thymeleaf

  return new WebEngineContext(
      configuration, templateData, templateResolutionAttributes,
      webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(),
      webContext.getLocale(), Collections.EMPTY_MAP);
return new WebEngineContext(
    configuration, templateData, templateResolutionAttributes,
    webContext.getRequest(), webContext.getResponse(), webContext.getServletContext(),
    webContext.getLocale(), variables);
origin: thymeleaf/thymeleaf-extras-springsecurity

static ApplicationContext findRequiredWebApplicationContext(final IContext context) {
  final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext();
  WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  if (wac == null) {
    final Enumeration<String> attrNames = servletContext.getAttributeNames();
    while (attrNames.hasMoreElements()) {
      final String attrName = attrNames.nextElement();
      final Object attrValue = servletContext.getAttribute(attrName);
      if (attrValue instanceof WebApplicationContext) {
        if (wac != null) {
          throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
              "DispatcherServlet registered with publishContext=true?");
        }
        wac = (WebApplicationContext) attrValue;
      }
    }
  }
  if (wac == null) {
    throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
  }
  return wac;
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity5

static ApplicationContext findRequiredWebApplicationContext(final IContext context) {
  final javax.servlet.ServletContext servletContext = ((IWebContext)context).getServletContext();
  WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  if (wac == null) {
    final Enumeration<String> attrNames = servletContext.getAttributeNames();
    while (attrNames.hasMoreElements()) {
      final String attrName = attrNames.nextElement();
      final Object attrValue = servletContext.getAttribute(attrName);
      if (attrValue instanceof WebApplicationContext) {
        if (wac != null) {
          throw new IllegalStateException("No unique WebApplicationContext found: more than one " +
              "DispatcherServlet registered with publishContext=true?");
        }
        wac = (WebApplicationContext) attrValue;
      }
    }
  }
  if (wac == null) {
    throw new IllegalStateException("No WebApplicationContext found: no ContextLoaderListener registered?");
  }
  return wac;
}
origin: thymeleaf/thymeleaf-extras-springsecurity

final ServletContext servletContext = webContext.getServletContext();
origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  final int spaceIndex = attrValue.indexOf(' ');
  final String url =
      (spaceIndex < 0? attrValue : attrValue.substring(spaceIndex + 1)).trim();
  final String method =
      (spaceIndex < 0? "GET" : attrValue.substring(0, spaceIndex)).trim();
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
            IWebContext.class.getName() + "). Spring Security integration can only be used in " +
            "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingUrlCheck(
      url, method, authentication, request, servletContext);
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity3

final ServletContext servletContext = webContext.getServletContext();
origin: org.everit.osgi.bundles/org.everit.osgi.bundles.org.thymeleaf.thymeleaf

public InputStream getResourceAsStream(final TemplateProcessingParameters templateProcessingParameters, final String resourceName) {
  
  Validate.notNull(templateProcessingParameters, "Template Processing Parameters cannot be null");
  Validate.notNull(resourceName, "Resource name cannot be null");
  
  final IContext context = templateProcessingParameters.getContext();
  if (!(context instanceof IWebContext)) {
    throw new TemplateProcessingException(
        "Resource resolution by ServletContext with " +
        this.getClass().getName() + " can only be performed " +
        "when context implements " + IWebContext.class.getName() + 
        " [current context: " + context.getClass().getName() + "]");
  }
  
  final ServletContext servletContext = 
    ((IWebContext)context).getServletContext();
  if (servletContext == null) {
    throw new TemplateProcessingException("Thymeleaf context returned a null ServletContext");
  }
  
  return servletContext.getResourceAsStream(resourceName);
  
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity4

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  final int spaceIndex = attrValue.indexOf(' ');
  final String url =
      (spaceIndex < 0? attrValue : attrValue.substring(spaceIndex + 1)).trim();
  final String method =
      (spaceIndex < 0? "GET" : attrValue.substring(0, spaceIndex)).trim();
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
            IWebContext.class.getName() + "). Spring Security integration can only be used in " +
            "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingUrlCheck(
      url, method, authentication, request, servletContext);
}
origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
}

origin: thymeleaf/thymeleaf-extras-springsecurity

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
  
}

origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity4

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
}

origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity3

@Override
protected boolean isVisible(
    final ITemplateContext context, final IProcessableElementTag tag,
    final AttributeName attributeName, final String attributeValue) {
  final String attrValue = (attributeValue == null? null : attributeValue.trim());
  if (attrValue == null || attrValue.length() == 0) {
    return false;
  }
  if (!(context instanceof IWebContext)) {
    throw new ConfigurationException(
        "Thymeleaf execution context is not a web context (implementation of " +
        IWebContext.class.getName() + "). Spring Security integration can only be used in " +
        "web environments.");
  }
  final IWebContext webContext = (IWebContext) context;
  
  final HttpServletRequest request = webContext.getRequest();
  final HttpServletResponse response = webContext.getResponse();
  final ServletContext servletContext = webContext.getServletContext();
  
  final Authentication authentication = AuthUtils.getAuthenticationObject();
  if (authentication == null) {
    return false;
  }
  
  return AuthUtils.authorizeUsingAccessExpression(
      context, attrValue, authentication, request, response, servletContext);
  
}

origin: thymeleaf/thymeleaf-extras-springsecurity

public Object buildObject(final IExpressionContext context, final String expressionObjectName) {
  if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      return AuthUtils.getAuthenticationObject();
    }
  }
  if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      // We retrieve it like this in order to give it the opportunity to come from cache
      final Authentication authentication =
          (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME);
      final IWebContext webContext = (IWebContext)context;
      final HttpServletRequest request = webContext.getRequest();
      final HttpServletResponse response = webContext.getResponse();
      final ServletContext servletContext = webContext.getServletContext();
      return new Authorization(context, authentication, request, response, servletContext);
    }
    return null;
  }
  return null;
}
origin: thymeleaf/thymeleaf-extras-springsecurity

public Object buildObject(final IExpressionContext context, final String expressionObjectName) {
  if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      return AuthUtils.getAuthenticationObject();
    }
  }
  if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      // We retrieve it like this in order to give it the opportunity to come from cache
      final Authentication authentication =
          (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME);
      final IWebContext webContext = (IWebContext)context;
      final HttpServletRequest request = webContext.getRequest();
      final HttpServletResponse response = webContext.getResponse();
      final ServletContext servletContext = webContext.getServletContext();
      return new Authorization(context, authentication, request, response, servletContext);
    }
    return null;
  }
  return null;
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity4

public Object buildObject(final IExpressionContext context, final String expressionObjectName) {
  if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      return AuthUtils.getAuthenticationObject();
    }
  }
  if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      // We retrieve it like this in order to give it the opportunity to come from cache
      final Authentication authentication =
          (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME);
      final IWebContext webContext = (IWebContext)context;
      final HttpServletRequest request = webContext.getRequest();
      final HttpServletResponse response = webContext.getResponse();
      final ServletContext servletContext = webContext.getServletContext();
      return new Authorization(context, authentication, request, response, servletContext);
    }
    return null;
  }
  return null;
}
origin: org.thymeleaf.extras/thymeleaf-extras-springsecurity3

public Object buildObject(final IExpressionContext context, final String expressionObjectName) {
  if (AUTHENTICATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      return AuthUtils.getAuthenticationObject();
    }
  }
  if (AUTHORIZATION_EXPRESSION_OBJECT_NAME.equals(expressionObjectName)) {
    if (context instanceof IWebContext) {
      // We retrieve it like this in order to give it the opportunity to come from cache
      final Authentication authentication =
          (Authentication) context.getExpressionObjects().getObject(AUTHENTICATION_EXPRESSION_OBJECT_NAME);
      final IWebContext webContext = (IWebContext)context;
      final HttpServletRequest request = webContext.getRequest();
      final HttpServletResponse response = webContext.getResponse();
      final ServletContext servletContext = webContext.getServletContext();
      return new Authorization(context, authentication, request, response, servletContext);
    }
    return null;
  }
  return null;
}
origin: thymeleaf/thymeleaf-extras-springsecurity

final ServletContext servletContext = webContext.getServletContext();
origin: thymeleaf/thymeleaf-extras-springsecurity

final ServletContext servletContext = webContext.getServletContext();
origin: thymeleaf/thymeleaf-extras-tiles2

final ServletContext servletContext = webContext.getServletContext();
org.thymeleaf.contextIWebContextgetServletContext

Javadoc

Returns the ServletContext object associated with the template execution.

Popular methods of IWebContext

  • getRequest
  • getHttpServletRequest
    Returns the HttpServletRequest object associated with the request this context has been created for
  • getHttpServletResponse
    Returns the HttpServletResponse object associated with the request this context has been created fo
  • getResponse
  • getHttpSession
    Returns the HttpSession object associated with the request this context has been created for.
  • getLocale
  • getSession
    Returns the HttpSession object associated with the template execution, or null if there is no sessi

Popular in Java

  • Creating JSON documents from java classes using gson
  • getSharedPreferences (Context)
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now