Tabnine Logo
HttpServlet
Code IndexAdd Tabnine to your IDE (free)

How to use
HttpServlet
in
javax.servlet.http

Best Java code snippets using javax.servlet.http.HttpServlet (Showing top 20 results out of 47,529)

Refine searchRefine arrow

  • HttpServletResponse
  • HttpServletRequest
  • ServletException
origin: javamelody/javamelody

/** {@inheritDoc} */
@Override
public void init(ServletConfig config) throws ServletException {
  super.init(config);
  Parameters.initialize(config.getServletContext());
  if (!Parameter.LOG.getValueAsBoolean()) {
    // si log désactivé dans serveur de collecte,
    // alors pas de log, comme dans webapp
    LOGGER.setLevel(Level.WARN);
  }
  // dans le serveur de collecte, on est sûr que log4j est disponible
  LOGGER.info("initialization of the collector servlet of the monitoring");
  httpAuth = new HttpAuth();
  try {
    collectorServer = new CollectorServer();
  } catch (final IOException e) {
    throw new ServletException(e.getMessage(), e);
  }
}
origin: igniterealtime/Openfire

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
  // add CORS headers for all HTTP responses (errors, etc.)
  if (boshManager.isCORSEnabled())
  {
    if (boshManager.isAllOriginsAllowed()) {
      // Set the Access-Control-Allow-Origin header to * to allow all Origin to do the CORS
      response.setHeader("Access-Control-Allow-Origin", HttpBindManager.HTTP_BIND_CORS_ALLOW_ORIGIN_DEFAULT);
    } else {
      // Get the Origin header from the request and check if it is in the allowed Origin Map.
      // If it is allowed write it back to the Access-Control-Allow-Origin header of the respond.
      final String origin = request.getHeader("Origin");
      if (boshManager.isThisOriginAllowed(origin)) {
        response.setHeader("Access-Control-Allow-Origin", origin);
      }
    }
    response.setHeader("Access-Control-Allow-Methods", HttpBindManager.HTTP_BIND_CORS_ALLOW_METHODS_DEFAULT);
    response.setHeader("Access-Control-Allow-Headers", HttpBindManager.HTTP_BIND_CORS_ALLOW_HEADERS_DEFAULT);
    response.setHeader("Access-Control-Max-Age", HttpBindManager.HTTP_BIND_CORS_MAX_AGE_DEFAULT);
  }
  super.service(request, response);
}
origin: googleapis/google-cloud-java

 @Override
 public void destroy() {
  executor.shutdownNow();
  super.destroy();
 }
}
origin: javax.servlet/servlet-api

throws ServletException, IOException
  long lastModified = getLastModified(req);
  if (lastModified == -1) {
  doGet(req, resp);
  } else {
  long ifModifiedSince = req.getDateHeader(HEADER_IFMODSINCE);
  if (ifModifiedSince < (lastModified / 1000 * 1000)) {
    maybeSetLastModified(resp, lastModified);
    doGet(req, resp);
  } else {
    resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
  long lastModified = getLastModified(req);
  maybeSetLastModified(resp, lastModified);
  doHead(req, resp);
  doPost(req, resp);
  doPut(req, resp);	
  doDelete(req, resp);
  doOptions(req,resp);
  doTrace(req,resp);
origin: net.lizhaoweb.spring.mvc/spring-mvc-core

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  logger.info("service('%s', '%s')", request, response);
  request.setCharacterEncoding(Constant.Charset.UTF8);
  response.setCharacterEncoding(Constant.Charset.UTF8);
  response.setContentType("text/html;charset=" + Constant.Charset.UTF8);
  super.service(request, response);
  session = request.getSession();
}
origin: org.apache.cxf/cxf-rt-transports-http

public boolean invoke(HttpServletRequest request, HttpServletResponse res, boolean returnErrors)
  throws ServletException {
  try {
    String pathInfo = request.getPathInfo() == null ? "" : request.getPathInfo();
    AbstractHTTPDestination d = destinationRegistry.getDestinationForPath(pathInfo, true);
      if (!isHideServiceList && (request.getRequestURI().endsWith(serviceListRelativePath)
        || request.getRequestURI().endsWith(serviceListRelativePath + "/")
        || StringUtils.isEmpty(pathInfo)
        serviceListGenerator.service(request, res);
      } else {
        d = destinationRegistry.checkRestfulRequest(pathInfo);
    throw new ServletException(e);
origin: konsoletyper/teavm

@Override
public void init(ServletConfig config) throws ServletException {
  super.init(config);
  wsFactory = WebSocketServletFactory.Loader.load(config.getServletContext(), wsPolicy);
  wsFactory.setCreator((req, resp) -> {
    ProxyWsClient proxyClient = (ProxyWsClient) req.getHttpServletRequest().getAttribute("teavm.ws.client");
    if (proxyClient == null) {
      return new CodeWsEndpoint(this);
    wsFactory.start();
  } catch (Exception e) {
    throw new ServletException(e);
origin: apache/oozie

  @SuppressWarnings("unchecked")
  public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    Enumeration<String> names = (Enumeration<String>) httpRequest.getHeaderNames();
    while (names.hasMoreElements()) {
      String name = names.nextElement();
      String value = httpRequest.getHeader(name);
      OOZIE_HEADERS.put(name, value);
    }
    servlet.service(request, response);
  }
}
origin: openmrs/openmrs-core

@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  log.debug("In service method for module servlet: " + request.getPathInfo());
  String servletName = request.getPathInfo();
  int end = servletName.indexOf("/", 1);
    response.setStatus(HttpServletResponse.SC_NOT_FOUND);
    return;
  servlet.service(request, response);
origin: org.apache.cxf/cxf-rt-transports-http

/**
 * {@inheritDoc}
 *
 * javax.http.servlet.HttpServlet does not let to override the code which deals with
 * unrecognized HTTP verbs such as PATCH (being standardized), WebDav ones, etc.
 * Thus we let CXF servlets process unrecognized HTTP verbs directly, otherwise we delegate
 * to HttpService
 */
@Override
public void service(ServletRequest req, ServletResponse res)
  throws ServletException, IOException {
  HttpServletRequest      request;
  HttpServletResponse     response;
  try {
    request = (HttpServletRequest) req;
    response = (HttpServletResponse) res;
  } catch (ClassCastException e) {
    throw new ServletException("Unrecognized HTTP request or response object");
  }
  String method = request.getMethod();
  if (KNOWN_HTTP_VERBS.contains(method)) {
    super.service(request, response);
  } else {
    handleRequest(request, response);
  }
}
origin: gocd/gocd

@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String url = request.getRequestURI().replaceAll("^/go/rails/", "/go/");
  servletHelper.getRequest(request).setRequestURI(url);
  rackServlet.service(request, response);
}
origin: javax.servlet/servlet-api

  response = (HttpServletResponse) res;
} catch (ClassCastException e) {
  throw new ServletException("non-HTTP request or response");
service(request, response);
origin: jamesagnew/hapi-fhir

@Override
protected void service(HttpServletRequest theReq, HttpServletResponse theResp) throws ServletException, IOException {
  theReq.setAttribute(REQUEST_START_TIME, new Date());
    method = RequestTypeEnum.valueOf(theReq.getMethod());
  } catch (IllegalArgumentException e) {
    super.service(theReq, theResp);
    return;
origin: com.liferay.portal/com.liferay.portal.kernel

throws IOException, ServletException {
String uri = request.getPathInfo();
  response.sendError(
    HttpServletResponse.SC_NOT_FOUND,
    "Path information is not specified");
  response.sendError(
    HttpServletResponse.SC_NOT_FOUND,
    "Path " + uri + " is invalid");
  response.sendError(
    HttpServletResponse.SC_NOT_FOUND,
    "No servlet registred for context " + paths[1]);
  delegate.service(request, response);
origin: com.semanticcms/semanticcms-news-rss

@Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  Object old = req.getAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE);
  try {
    req.setAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE, resp);
    super.service(req, resp);
  } finally {
    req.setAttribute(RESPONSE_IN_REQUEST_ATTRIBUTE, old);
  }
}
origin: voldemort/voldemort

@Override
public void init() throws ServletException {
  super.init();
  // this.getServletContext().getAttribute("velocity");
}
origin: org.apache.activemq/activemq-all

@Override
protected void doOptions(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  response.addHeader("Accepts-Encoding", "gzip");
  super.doOptions(request, response);
}
origin: org.ow2.petals/petals-bc-rest

@Override
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  if ("PATCH".equalsIgnoreCase(request.getMethod())) {
    doPatch(request, response);
  } else {
    super.service(request, response);
  }
}
origin: com.atlassian.studio/studio-theme-fisheye-plugin

@Override
protected void service(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException
{
  if (!userIsSysadmin(request))
  {
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
      "Only system administrators can administrate Crucible");
    return;
  }
  super.service(request, response);
}
origin: sakaiproject/sakai

/**
 * Override service, adding the setup for legacy.
 */
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException
{
  // parse the parameters of the request, considering Unicode issues, into a ParameterParser
  ParameterParser parser = new ParameterParser(req);
  // make this available from the req as an attribute
  req.setAttribute(ATTR_PARAMS, parser);
  // Setup.setup(req, resp);
  super.service(req, resp);
}
javax.servlet.httpHttpServlet

Javadoc

Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A subclass of HttpServlet must override at least one method, usually one of these:
  • doGet, if the servlet supports HTTP GET requests
  • doPost, for HTTP POST requests
  • doPut, for HTTP PUT requests
  • doDelete, for HTTP DELETE requests
  • init and destroy, to manage resources that are held for the life of the servlet
  • getServletInfo, which the servlet uses to provide information about itself

There's almost no reason to override the service method. service handles standard HTTP requests by dispatching them to the handler methods for each HTTP request type (the doMethod methods listed above).

Likewise, there's almost no reason to override the doOptions and doTrace methods.

Servlets typically run on multithreaded servers, so be aware that a servlet must handle concurrent requests and be careful to synchronize access to shared resources. Shared resources include in-memory data such as instance or class variables and external objects such as files, database connections, and network connections. See the Java Tutorial on Multithreaded Programming for more information on handling multiple threads in a Java program.

Most used methods

  • init
  • service
    Receives standard HTTP requests from the publicservice method and dispatches them to the doXXX metho
  • destroy
  • doOptions
    Called by the server (via the service method) to allow a servlet to handle a OPTIONS request. The OP
  • doGet
    Called by the server (via the service method) to allow a servlet to handle a GET request.Overriding
  • doPost
    Called by the server (via the service method) to allow a servlet to handle a POST request. The HTTP
  • doTrace
    Called by the server (via the service method) to allow a servlet to handle a TRACE request. A TRACE
  • doHead
    Receives an HTTP HEAD request from the protectedservice method and handles the request. The client s
  • doPut
    Called by the server (via the service method) to allow a servlet to handle a PUT request. The PUT op
  • getLastModified
    Returns the time the HttpServletRequest object was last modified, in milliseconds since midnight Jan
  • doDelete
    Called by the server (via the service method) to allow a servlet to handle a DELETE request. The DEL
  • getServletContext
  • doDelete,
  • getServletContext,
  • getAllDeclaredMethods,
  • maybeSetLastModified,
  • getInitParameter,
  • getServletConfig,
  • log,
  • getServletName,
  • getInitParameterNames,
  • getServletInfo

Popular in Java

  • Creating JSON documents from java classes using gson
  • compareTo (BigDecimal)
  • addToBackStack (FragmentTransaction)
  • getContentResolver (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • JLabel (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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