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

How to use
ServletException
in
javax.servlet

Best Java code snippets using javax.servlet.ServletException (Showing top 20 results out of 11,610)

Refine searchRefine arrow

  • HttpServletRequest
  • HttpServletResponse
  • ServletContext
  • ServletConfig
  • PrintWriter
  • FilterChain
  • RequestDispatcher
  • HttpSession
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HessianSkeleton skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    Enumeration<String> enumeration = request.getHeaderNames();
    while (enumeration.hasMoreElements()) {
      String key = enumeration.nextElement();
      if (key.startsWith(Constants.DEFAULT_EXCHANGER)) {
        RpcContext.getContext().setAttachment(key.substring(Constants.DEFAULT_EXCHANGER.length()),
            request.getHeader(key));
      }
    }
    try {
      skeleton.invoke(request.getInputStream(), response.getOutputStream());
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: jenkinsci/jenkins

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
  try {
    chain.doFilter(request,response);
  } catch (ServletException e) {
    Throwable t = e.getRootCause();
    if (t instanceof JellyTagException) {
      JellyTagException jte = (JellyTagException) t;
      Throwable cause = jte.getCause();
      if (cause instanceof AcegiSecurityException) {
        AcegiSecurityException se = (AcegiSecurityException) cause;
        throw new ServletException(se);
      }
    }
    throw e;
  }
}
origin: BroadleafCommerce/BroadleafCommerce

  @Override
  public void doFilterInternal(HttpServletRequest baseRequest, HttpServletResponse baseResponse, FilterChain chain) throws IOException, ServletException {
    try {
      super.doFilterInternal(baseRequest, baseResponse, chain);
    } catch (ServletException e) {
      if (e.getCause() instanceof StaleStateServiceException) {
        LOG.debug("Stale state detected", e);
        baseResponse.setStatus(HttpServletResponse.SC_CONFLICT);
        baseResponse.getWriter().write("Stale State Detected\n");
        baseResponse.getWriter().write(e.getMessage() + "\n");
      } else if (e.getCause() instanceof ServiceException) {
        //if authentication is null and CSRF token is invalid, must be session time out
        if (SecurityContextHolder.getContext().getAuthentication() == null && failureHandler != null) {
          baseRequest.setAttribute("sessionTimeout", true);
          failureHandler.onAuthenticationFailure(baseRequest, baseResponse, new SessionAuthenticationException("Session Time Out"));
        } else {
          throw e;
        }
      } else {
        throw e;
      }
    }
  }
}
origin: pentaho/pentaho-kettle

if ( isJettyMode() && !request.getContextPath().startsWith( CONTEXT_PATH ) ) {
 return;
String jobName = request.getParameter( "name" );
String id = request.getParameter( "id" );
String root = request.getRequestURI() == null ? StatusServletUtils.PENTAHO_ROOT
 : request.getRequestURI().substring( 0, request.getRequestURI().indexOf( CONTEXT_PATH ) );
int startLineNr = Const.toInt( request.getParameter( "from" ), 0 );
response.setStatus( HttpServletResponse.SC_OK );
 response.setContentType( "text/xml" );
 response.setCharacterEncoding( Const.XML_ENCODING );
} else {
 response.setContentType( "text/html;charset=UTF-8" );
   response.flushBuffer();
  } catch ( KettleException e ) {
   throw new ServletException( "Unable to get the job status in XML format", e );
  response.setContentType( "text/html" );
origin: pentaho/pentaho-kettle

if ( isJettyMode() && !request.getContextPath().startsWith( CONTEXT_PATH ) ) {
 return;
 logDebug( BaseMessages.getString( PKG, "GetStatusServlet.StatusRequested" ) );
response.setStatus( HttpServletResponse.SC_OK );
String root = request.getRequestURI() == null ? StatusServletUtils.PENTAHO_ROOT
 : request.getRequestURI().substring( 0, request.getRequestURI().indexOf( CONTEXT_PATH ) );
String prefix = isJettyMode() ? StatusServletUtils.STATIC_PATH : root + StatusServletUtils.RESOURCES_PATH;
boolean useXML = "Y".equalsIgnoreCase( request.getParameter( "xml" ) );
 response.setContentType( "text/xml" );
 response.setCharacterEncoding( Const.XML_ENCODING );
} else {
 response.setContentType( "text/html;charset=UTF-8" );
 out.print( XMLHandler.getXMLHeader( Const.XML_ENCODING ) );
 SlaveServerStatus serverStatus = new SlaveServerStatus();
 serverStatus.setStatusDescription( "Online" );
  out.println( serverStatus.getXML() );
 } catch ( KettleException e ) {
  throw new ServletException( "Unable to get the server status in XML format", e );
 out.println( "<HTML>" );
 out.println( "<HEAD><TITLE>"
   + BaseMessages.getString( PKG, "GetStatusServlet.KettleSlaveServerStatus" ) + "</TITLE>" );
origin: apache/hbase

response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
      null, true, 8192, true);
out = pageContext.getOut();
_jspx_out = out;
_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
out.print( request.getParameter("pageTitle"));
out.write("</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <meta name=\"description\" content=\"\">\n    <meta name=\"author\" content=\"\">\n\n    <link href=\"/static/css/bootstrap.min.css\" rel=\"stylesheet\">\n    <link href=\"/static/css/bootstrap-theme.min.css\" rel=\"stylesheet\">\n    <link href=\"/static/css/hbase.css\" rel=\"stylesheet\">\n  </head>\n  <body>\n    <div class=\"navbar  navbar-fixed-top navbar-default\">\n      <div class=\"container-fluid\">\n        <div class=\"navbar-header\">\n          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\"\n                  data-target=\".navbar-collapse\">\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n          </button>\n          <a class=\"navbar-brand\" href=\"/rs-status\">\n            <img src=\"/static/hbase_logo_small.png\" alt=\"HBase Logo\"/>\n          </a>\n        </div>\n        <div class=\"collapse navbar-collapse\">\n          <ul class=\"nav navbar-nav\">\n            <li><a href=\"/rs-status\">Home</a></li>\n");
out.write("            <li><a href=\"/processRS.jsp\">Process Metrics</a></li>\n            <li><a href=\"/logs/\">Local Logs</a></li>\n            <li><a href=\"/logLevel\">Log Level</a></li>\n            <li><a href=\"/dump\">Debug Dump</a></li>\n            <li><a href=\"/jmx\">Metrics Dump</a></li>\n            ");
  out.clearBuffer();
 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
 else throw new ServletException(t);
origin: ehcache/ehcache3

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
 resp.setContentType("text/html");
 PrintWriter out = resp.getWriter();
 out.println("<html>");
 out.println("<head>");
 out.println("<title>Peeper</title>");
 out.println("</head>");
 out.println("<body>");
 out.println("<h1>Peeper!</h1>");
 try {
  List<String> allPeeps = PeeperServletContextListener.DATA_STORE.findAllPeeps();
  for (String peep : allPeeps) {
   out.println(peep);
   out.print("<br/><br/>");
  }
 } catch (Exception e) {
  throw new ServletException("Error listing peeps", e);
 }
 out.println("<form name=\"htmlform\" method=\"post\" action=\"peep\">");
 out.println("Enter your peep: <input type=\"text\" name=\"peep\" maxlength=\"142\" size=\"30\"/>");
 out.println("<input type=\"submit\" value=\"Peep!\"/>");
 out.println("</form>");
 out.println("</body>");
 out.println("</html>");
}
origin: openmrs/openmrs-core

String page = httpRequest.getParameter("page");
Map<String, Object> referenceMap = new HashMap<>();
if (httpRequest.getSession().getAttribute(FilterUtil.LOCALE_ATTRIBUTE) != null) {
  referenceMap
      .put(FilterUtil.LOCALE_ATTRIBUTE, httpRequest.getSession().getAttribute(FilterUtil.LOCALE_ATTRIBUTE));
      httpResponse.setContentType("text/html");
      renderTemplate(REVIEW_CHANGES, referenceMap, httpResponse);
      return;
    httpRequest.getSession().setAttribute(FilterUtil.LOCALE_ATTRIBUTE, localeParameter);
    referenceMap.put(FilterUtil.LOCALE_ATTRIBUTE, localeParameter);
      throw new ServletException("Got interrupted while trying to sleep thread", e);
  httpResponse.setContentType("text/json");
  httpResponse.setHeader("Cache-Control", "no-cache");
  Map<String, Object> result = new HashMap<>();
  if (updateJob != null) {
  httpResponse.getWriter().write(jsonText);
origin: apache/incubator-druid

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
  throws IOException, ServletException
{
 HttpServletRequest request;
 HttpServletResponse response;
 try {
  request = (HttpServletRequest) req;
  response = (HttpServletResponse) res;
 }
 catch (ClassCastException e) {
  throw new ServletException("non-HTTP request or response");
 }
 if (redirectInfo.doLocal(request.getRequestURI())) {
  chain.doFilter(request, response);
 } else {
  URL url = redirectInfo.getRedirectURL(request.getQueryString(), request.getRequestURI());
  log.debug("Forwarding request to [%s]", url);
  if (url == null) {
   // We apparently have nothing to redirect to, so let's do a Service Unavailable
   response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE);
   return;
  }
  response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
  response.setHeader("Location", url.toString());
 }
}
origin: opensourceBIM/BIMserver

OAuthAuthzRequest oauthRequest = null;
String authType = request.getParameter("auth_type");
if (request.getParameter("token") == null) {
  String location = "/apps/bimviews/?page=OAuth&auth_type=" + authType + "&client_id=" + request.getParameter("client_id") + "&response_type=" + request.getParameter("response_type") + "&redirect_uri="
      + request.getParameter("redirect_uri");
  if (request.getParameter("state") != null) {
  httpServletResponse.sendRedirect(location);
  return;
      throw new ServletException("No auth found for token " + token);
        httpServletResponse.getWriter().write("Service token (copy&paste this into your application): <br/><br/><input type=\"text\" style=\"width: 1000px\" value=\"" + oauthCode.getCode() + "\"/><br/><br/>");
        httpServletResponse.getWriter().write("Service address: <br/><br/><input type=\"text\" style=\"width: 1000px\" value=\"" + siteAddress + "/services/" + auth.getService().getOid()  + "\"/><br/><br/>");
      } else {
        URI uri = makeUrl(redirectURI, oauthCode, builder);
      httpServletResponse.getWriter().println("No redirectURI provided");
      httpServletResponse.getWriter().println("Would have redirected to: " + uri);
origin: apache/incubator-dubbo

@Override
public void handle(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
  String uri = request.getRequestURI();
  HttpInvokerServiceExporter skeleton = skeletonMap.get(uri);
  if (!request.getMethod().equalsIgnoreCase("POST")) {
    response.setStatus(500);
  } else {
    RpcContext.getContext().setRemoteAddress(request.getRemoteAddr(), request.getRemotePort());
    try {
      skeleton.handleRequest(request, response);
    } catch (Throwable e) {
      throw new ServletException(e);
    }
  }
}
origin: org.kuali.rice/rice-ksb-client-impl

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  byte[] clientKeyStoreData = (byte[])request.getSession().getAttribute(CLIENT_KEYSTORE_DATA);
  request.getSession().removeAttribute(CLIENT_KEYSTORE_DATA);
  if (clientKeyStoreData == null) {
    throw new ServletException("No keystore file was specified.");
  }
  response.setContentType(MIME_TYPE);
  response.setContentLength(clientKeyStoreData.length);
  response.setHeader("Content-disposition", "attachment; filename="+extractFileName(request));
  response.getOutputStream().write(clientKeyStoreData);
  response.getOutputStream().close();
}
origin: spring-projects/spring-framework

  @Override
  public void handleRequest(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    assertSame(request, req);
    assertSame(response, res);
    String exception = request.getParameter("exception");
    if ("ServletException".equals(exception)) {
      throw new ServletException("test");
    }
    if ("IOException".equals(exception)) {
      throw new IOException("test");
    }
    res.getWriter().write("myResponse");
  }
});
origin: googleapis/google-cloud-java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
  throws ServletException, IOException {
 try {
  String classNames = req.getParameter("classes");
  PrintWriter out = resp.getWriter();
  List<Class<?>> testClasses = loadClasses(classNames.split("[\\r\\n]+"));
  String output = runTests(testClasses, req, resp);
  out.append(output);
  out.close();
 } catch (Exception e) {
  throw new ServletException(e);
 }
}
origin: com.atlassian.plugins/atlassian-connect-server-integration-tests-support

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
  if (req.getRequestURI().endsWith("/webhook") || req.getRequestURI().endsWith("-lifecycle")) {
    String version = req.getHeader(HttpHeaderNames.ATLASSIAN_CONNECT_VERSION);
    final String authorizationHeader = getAuthorizationHeader(req);
    try {
      webHooksQueue.push(new JsonWebHookBody(getFullURL(req), JSON.parse(IOUtils.toString(req.getReader())), version, authorizationHeader));
      resp.getWriter().write("OKEY DOKEY");
    } catch (ParserException e) {
      throw new ServletException(e);
    }
  }
}
origin: apache/hive

 public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
    throws java.io.IOException, javax.servlet.ServletException {
final java.lang.String _jspx_method = request.getMethod();
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method) && !javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSPs only permit GET POST or HEAD");
return;
   response.setContentType("text/html;charset=UTF-8");
   pageContext = _jspxFactory.getPageContext(this, request, response,
         null, true, 8192, true);
  Configuration conf = (Configuration)ctx.getAttribute("hive.conf");
  long startcode = conf.getLong("startcode", System.currentTimeMillis());
  SessionManager sessionManager =
      (SessionManager)ctx.getAttribute("hive.sm");
  String remoteUser = request.getRemoteUser();
    if (out != null && out.getBufferSize() != 0)
     try {
      if (response.isCommitted()) {
       out.flush();
      } else {
    else throw new ServletException(t);
origin: spring-projects/spring-framework

for (Enumeration<String> en = request.getAttributeNames(); en.hasMoreElements();) {
  String attribute = en.nextElement();
  if (model.containsKey(attribute) && !this.allowRequestOverride) {
    throw new ServletException("Cannot expose request attribute '" + attribute +
      "' because of an existing model object of the same name");
  Object attributeValue = request.getAttribute(attribute);
  if (logger.isDebugEnabled()) {
    exposed = exposed != null ? exposed : new LinkedHashMap<>();
HttpSession session = request.getSession(false);
if (session != null) {
  Map<String, Object> exposed = null;
  for (Enumeration<String> en = session.getAttributeNames(); en.hasMoreElements();) {
    String attribute = en.nextElement();
    if (model.containsKey(attribute) && !this.allowSessionOverride) {
      throw new ServletException("Cannot expose session attribute '" + attribute +
        "' because of an existing model object of the same name");
    Object attributeValue = session.getAttribute(attribute);
    if (logger.isDebugEnabled()) {
      exposed = exposed != null ? exposed : new LinkedHashMap<>();
  throw new ServletException(
      "Cannot expose bind macro helper '" + SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE +
      "' because of an existing model object of the same name");
origin: org.astrogrid/astrogrid-registry-server

/**
 * Handles the HTTP GET method.
 * The response to GET is a form for editing capabilities.
 * The expression of the form is currently done by a JSP, because the form
 * is static. In future versions, the form might be produced by XSLT
 * from the current content of the resource document. Therefore, this servlet
 * is the preferred entry-point and it delegates to the JSP.
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response)
  throws ServletException, IOException {
 String ivornString = request.getParameter("IVORN");
 if (ivornString == null || ivornString.trim().length() == 0) {
  throw new ServletException("No identifier was given for the resource; " +
                "parameter IVORN is not set.");
 }
 String encodedIvorn = URLEncoder.encode(ivornString, "UTF-8");
 String redirectUri = "/registration/ServiceMetadataForm.jsp?IVORN=" + 
            encodedIvorn;
 request.getRequestDispatcher(redirectUri).forward(request, response);
}

origin: BroadleafCommerce/BroadleafCommerce

HttpServletRequest request = (HttpServletRequest) sRequest;
HttpServletResponse response = (HttpServletResponse) sResponse;
HttpSession session = request.getSession(false);
  chain.doFilter(request, response);
String activeIdSessionValue = (session == null) ? null : (String) session.getAttribute(SESSION_ATTR);
if (StringUtils.isNotBlank(activeIdSessionValue) && request.isSecure()) {
    return;
} else if (request.isSecure() && session != null) {
    token = RandomGenerator.generateRandomId("SHA1PRNG", 32);
  } catch (NoSuchAlgorithmException e) {
    throw new ServletException(e);
  session.setAttribute(SESSION_ATTR, token);
  cookieUtils.setCookieValue(response, SessionFixationProtectionCookie.COOKIE_NAME, encryptedActiveIdValue, "/", -1, true);
chain.doFilter(request, response);
origin: spring-projects/spring-framework

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
    throws ServletException, IOException {
  if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
    throw new ServletException("ResourceUrlEncodingFilter only supports HTTP requests");
  }
  ResourceUrlEncodingRequestWrapper wrappedRequest =
      new ResourceUrlEncodingRequestWrapper((HttpServletRequest) request);
  ResourceUrlEncodingResponseWrapper wrappedResponse =
      new ResourceUrlEncodingResponseWrapper(wrappedRequest, (HttpServletResponse) response);
  filterChain.doFilter(wrappedRequest, wrappedResponse);
}
javax.servletServletException

Javadoc

Defines a general exception a servlet can throw when it encounters difficulty.

Most used methods

  • <init>
    Constructs a new servlet exception when the servlet needs to throw an exception and include a messag
  • getRootCause
    Returns the exception that caused this servlet exception.
  • getMessage
  • getCause
  • printStackTrace
  • toString
  • initCause
  • getLocalizedMessage
  • getStackTrace
  • setStackTrace
  • addSuppressed
  • addSuppressed

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • getSupportFragmentManager (FragmentActivity)
  • setContentView (Activity)
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JTable (javax.swing)
  • Top plugins for WebStorm
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