javax.servlet.http.HttpServlet.getServletName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中javax.servlet.http.HttpServlet.getServletName()方法的一些代码示例,展示了HttpServlet.getServletName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpServlet.getServletName()方法的具体详情如下:
包路径:javax.servlet.http.HttpServlet
类名称:HttpServlet
方法名:getServletName

HttpServlet.getServletName介绍

暂无

代码示例

代码示例来源:origin: com.google.inject.extensions/guice-servlet

assertEquals(Key.get(HttpServlet.class).toString(), mockServlet.getServletName());

代码示例来源:origin: org.apache.tapestry/com.springsource.org.apache.tapestry

public String getActivatorName()
{
  return _httpServlet.getServletName();
}

代码示例来源:origin: org.apache.tapestry/tapestry-framework

public String getActivatorName()
{
  return _httpServlet.getServletName();
}

代码示例来源:origin: com.atlassian.plugins/remotable-plugins-servlet-kit

@Override
public String getServletName()
{
  return delegate.get().getServletName();
}

代码示例来源:origin: com.atlassian.pluginkit/servlet-kit

@Override
public String getServletName()
{
  return delegate.get().getServletName();
}

代码示例来源:origin: org.apache.tapestry/com.springsource.org.apache.tapestry

static String noApplicationSpecification(HttpServlet servlet)
{
  return _formatter.format("no-application-specification", servlet.getServletName());
}

代码示例来源:origin: org.apache.tapestry/tapestry-framework

static String noApplicationSpecification(HttpServlet servlet)
{
  return _formatter.format("no-application-specification", servlet.getServletName());
}

代码示例来源:origin: org.apache.axis/com.springsource.org.apache.axis

/**
 * put the engine back in to the context.
 * @param context servlet context to use
 * @param engine reference to the engine. If null, the engine is removed
 */
private static void storeEngine(HttpServlet servlet, AxisServer engine) {
  ServletContext context = servlet.getServletContext();
  String axisServletName = servlet.getServletName();
  if (engine == null) {
    context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE);
    // find if there is other AxisEngine in Context
    AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE);
    // no other AxisEngine in ServletContext
    if (server != null && servlet.getServletName().equals(server.getName())) {
      context.removeAttribute(ATTR_AXIS_ENGINE);
    }
  } else {
    if (context.getAttribute(ATTR_AXIS_ENGINE) == null) {
      // first Axis servlet to store its AxisEngine
      // use default name
      context.setAttribute(ATTR_AXIS_ENGINE, engine);
    }
    context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine);
  }
}

代码示例来源:origin: axis/axis

/**
 * put the engine back in to the context.
 * @param context servlet context to use
 * @param engine reference to the engine. If null, the engine is removed
 */
private static void storeEngine(HttpServlet servlet, AxisServer engine) {
  ServletContext context = servlet.getServletContext();
  String axisServletName = servlet.getServletName();
  if (engine == null) {
    context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE);
    // find if there is other AxisEngine in Context
    AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE);
    // no other AxisEngine in ServletContext
    if (server != null && servlet.getServletName().equals(server.getName())) {
      context.removeAttribute(ATTR_AXIS_ENGINE);
    }
  } else {
    if (context.getAttribute(ATTR_AXIS_ENGINE) == null) {
      // first Axis servlet to store its AxisEngine
      // use default name
      context.setAttribute(ATTR_AXIS_ENGINE, engine);
    }
    context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine);
  }
}

代码示例来源:origin: org.apache.axis/axis

/**
 * put the engine back in to the context.
 * @param context servlet context to use
 * @param engine reference to the engine. If null, the engine is removed
 */
private static void storeEngine(HttpServlet servlet, AxisServer engine) {
  ServletContext context = servlet.getServletContext();
  String axisServletName = servlet.getServletName();
  if (engine == null) {
    context.removeAttribute(axisServletName + ATTR_AXIS_ENGINE);
    // find if there is other AxisEngine in Context
    AxisServer server = (AxisServer) context.getAttribute(ATTR_AXIS_ENGINE);
    // no other AxisEngine in ServletContext
    if (server != null && servlet.getServletName().equals(server.getName())) {
      context.removeAttribute(ATTR_AXIS_ENGINE);
    }
  } else {
    if (context.getAttribute(ATTR_AXIS_ENGINE) == null) {
      // first Axis servlet to store its AxisEngine
      // use default name
      context.setAttribute(ATTR_AXIS_ENGINE, engine);
    }
    context.setAttribute(axisServletName + ATTR_AXIS_ENGINE, engine);
  }
}

代码示例来源:origin: Talend/tesb-rt-se

@Override
public void afterPropertiesSet() throws Exception {
  HttpContext actualHttpContext = (httpContext == null) 
    ? httpService.createDefaultHttpContext()
    : httpContext;
  final Dictionary<String, String> initParams = new Hashtable<String, String>();
  // The servlet will always have to match on uri prefix as some endpoints may do so
  initParams.put("matchOnUriPrefix", "true");
  
  try {
    String servletName = servlet.getServletName();
    initParams.put("servlet-name", servletName);
  } catch (Exception e) {
    // If getServletName is not implemented the default is to throw an exception
    // In this case we simply do not set a servlet name
  }
  
  httpService.registerServlet(alias, servlet, initParams, actualHttpContext);
  alreadyRegistered = true;
}

代码示例来源:origin: axis/axis

/**
 * Get an engine from the servlet context; robust againt serialization
 * issues of hot-updated webapps. Remember than if a webapp is marked
 * as distributed, there is more than 1 servlet context, hence more than
 * one AxisEngine instance
 * @param servlet
 * @return the engine or null if either the engine couldnt be found or
 *         the attribute wasnt of the right type
 */
private static AxisServer retrieveEngine(HttpServlet servlet) {
  Object contextObject = servlet.getServletContext().getAttribute(servlet.getServletName() + ATTR_AXIS_ENGINE);
  if (contextObject == null) {
    // if AxisServer not found :
    // fall back to the "default" AxisEngine
    contextObject = servlet.getServletContext().getAttribute(ATTR_AXIS_ENGINE);
  }
  if (contextObject instanceof AxisServer) {
    AxisServer server = (AxisServer) contextObject;
    // if this is "our" Engine
    if (server != null && servlet.getServletName().equals(server.getName())) {
      return server;
    }
    return null;
  } else {
    return null;
  }
 }

代码示例来源:origin: org.tinygroup/weblayer

public void reallyProcess(String urlString, WebContext context) {
  HttpServletRequest request = context.getRequest();
  HttpServletResponse response = context.getResponse();
  try {
    servlet.service(request, response);
  } catch (Exception e) {
    logger.errorMessage("servlet:{}执行出错", e, servlet.getServletName());
    throw new RuntimeException("servlet执行出错", e);
  }
}

代码示例来源:origin: org.apache.axis/com.springsource.org.apache.axis

/**
 * Get an engine from the servlet context; robust againt serialization
 * issues of hot-updated webapps. Remember than if a webapp is marked
 * as distributed, there is more than 1 servlet context, hence more than
 * one AxisEngine instance
 * @param servlet
 * @return the engine or null if either the engine couldnt be found or
 *         the attribute wasnt of the right type
 */
private static AxisServer retrieveEngine(HttpServlet servlet) {
  Object contextObject = servlet.getServletContext().getAttribute(servlet.getServletName() + ATTR_AXIS_ENGINE);
  if (contextObject == null) {
    // if AxisServer not found :
    // fall back to the "default" AxisEngine
    contextObject = servlet.getServletContext().getAttribute(ATTR_AXIS_ENGINE);
  }
  if (contextObject instanceof AxisServer) {
    AxisServer server = (AxisServer) contextObject;
    // if this is "our" Engine
    if (server != null && servlet.getServletName().equals(server.getName())) {
      return server;
    }
    return null;
  } else {
    return null;
  }
 }

代码示例来源:origin: org.apache.tapestry/tapestry-framework

private IApplicationSpecification constructStandinSpecification(HttpServlet servlet)
{
  String servletName = servlet.getServletName();
  ApplicationSpecification result = new ApplicationSpecification();
  // Pretend the file exists in the most common expected location.
  Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application");
  result.setSpecificationLocation(virtualLocation);
  result.setName(servletName);
  return result;
}

代码示例来源:origin: org.apache.tapestry/com.springsource.org.apache.tapestry

private IApplicationSpecification constructStandinSpecification(HttpServlet servlet)
{
  String servletName = servlet.getServletName();
  ApplicationSpecification result = new ApplicationSpecification();
  // Pretend the file exists in the most common expected location.
  Resource virtualLocation = new ContextResource(servlet.getServletContext(), "/WEB-INF/" + servletName + ".application");
  result.setSpecificationLocation(virtualLocation);
  result.setName(servletName);
  return result;
}

代码示例来源:origin: bigpuritz/netty-servlet-bridge

@Override
public RequestDispatcher getRequestDispatcher(String path) {
  Collection<ServletConfiguration> colls = ServletBridgeWebapp.get().getWebappConfig().getServletConfigurations();
  HttpServlet servlet = null;
  String servletName = null;
  for (ServletConfiguration configuration : colls) {
    if (configuration.matchesUrlPattern(path)) {
      servlet = configuration.getHttpComponent();
      servletName = configuration.getHttpComponent().getServletName();
    }
  }
  return new RequestDispatcherImpl(servletName, path, servlet);
}

代码示例来源:origin: org.apache.tapestry/com.springsource.org.apache.tapestry

private Resource findApplicationSpecification(HttpServlet servlet)
{
  String path = servlet.getInitParameter(APP_SPEC_PATH_PARAM);
  if (path != null)
    return _classpathResourceFactory.newResource(path);
  ServletContext context = servlet.getServletContext();
  String servletName = servlet.getServletName();
  String expectedName = servletName + ".application";
  Resource webInfLocation = new ContextResource(context, "/WEB-INF/");
  Resource webInfAppLocation = webInfLocation.getRelativeResource(servletName + "/");
  Resource result = check(webInfAppLocation, expectedName);
  if (result != null)
    return result;
  
  result = check(webInfLocation, expectedName);
  if (result != null)
    return result;
  
  // Now look for it in classpath, just in case
  
  result = _classpathResourceFactory.newResource(expectedName);
  if (result != null && result.getResourceURL() != null)
    return result;
  
  return null;
}

代码示例来源:origin: org.apache.tapestry/tapestry-framework

private Resource findApplicationSpecification(HttpServlet servlet)
{
  String path = servlet.getInitParameter(APP_SPEC_PATH_PARAM);
  if (path != null)
    return _classpathResourceFactory.newResource(path);
  ServletContext context = servlet.getServletContext();
  String servletName = servlet.getServletName();
  String expectedName = servletName + ".application";
  Resource webInfLocation = new ContextResource(context, "/WEB-INF/");
  Resource webInfAppLocation = webInfLocation.getRelativeResource(servletName + "/");
  Resource result = check(webInfAppLocation, expectedName);
  if (result != null)
    return result;
  
  result = check(webInfLocation, expectedName);
  if (result != null)
    return result;
  
  // Now look for it in classpath, just in case
  
  result = _classpathResourceFactory.newResource(expectedName);
  if (result != null && result.getResourceURL() != null)
    return result;
  
  return null;
}

代码示例来源:origin: GoogleCloudPlatform/appengine-tck

@Override
  public void run() {
    Entity entity = null;
    if (marker != null) {
      entity = dsUtil.getMarker(marker);
    }

    HttpServletRequest req = DeferredTaskContext.getCurrentRequest();
    if (marker == null || entity != null) {
      dsUtil.addRequestToDataStore(req, testParams);
    }

    HttpServletResponse resp = DeferredTaskContext.getCurrentResponse();
    resp.setHeader("foo", "bar"); // try to do something more useful with response

    HttpServlet servlet = DeferredTaskContext.getCurrentServlet();
    String sn = servlet.getServletName();
    System.out.println("sn = " + sn);

    if (marker != null && entity == null) {
      DeferredTaskContext.markForRetry();
      dsUtil.putMarker(marker);
    } else {
      DeferredTaskContext.setDoNotRetry(true);
    }
  }
}

相关文章