当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletResponse.SC_INTERNAL_SERVER_ERROR属性代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR属性的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.SC_INTERNAL_SERVER_ERROR属性的具体用法?Java HttpServletResponse.SC_INTERNAL_SERVER_ERROR怎么用?Java HttpServletResponse.SC_INTERNAL_SERVER_ERROR使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.SC_INTERNAL_SERVER_ERROR属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSCFromHttpStatusLine

/**
 * Parses the Status-Line and extracts the status code.
 *
 * @param line The HTTP Status-Line (RFC2616, section 6.1)
 * @return The extracted status code or the code representing an
 * internal error if a valid status code cannot be extracted.
 */
private int getSCFromHttpStatusLine(String line) {
    int statusStart = line.indexOf(' ') + 1;

    if (statusStart < 1 || line.length() < statusStart + 3) {
        // Not a valid HTTP Status-Line
        log.warn(sm.getString("cgiServlet.runInvalidStatus", line));
        return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }

    String status = line.substring(statusStart, statusStart + 3);

    int statusCode;
    try {
        statusCode = Integer.parseInt(status);
    } catch (NumberFormatException nfe) {
        // Not a valid status code
        log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
        return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }

    return statusCode;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:29,代码来源:CGIServlet.java

示例2: getSCFromCGIStatusHeader

/**
 * Parses the CGI Status Header value and extracts the status code.
 *
 * @param value The CGI Status value of the form <code>
 *             digit digit digit SP reason-phrase</code>
 * @return The extracted status code or the code representing an
 * internal error if a valid status code cannot be extracted.
 */
private int getSCFromCGIStatusHeader(String value) {
    if (value.length() < 3) {
        // Not a valid status value
        log.warn(sm.getString("cgiServlet.runInvalidStatus", value));
        return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }

    String status = value.substring(0, 3);

    int statusCode;
    try {
        statusCode = Integer.parseInt(status);
    } catch (NumberFormatException nfe) {
        // Not a valid status code
        log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
        return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    }

    return statusCode;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:CGIServlet.java

示例3: getSCFromHttpStatusLine

/**
 * Parses the Status-Line and extracts the status code.
 *
 * @param line
 *            The HTTP Status-Line (RFC2616, section 6.1)
 * @return The extracted status code or the code representing an
 *         internal error if a valid status code cannot be extracted.
 */
private int getSCFromHttpStatusLine(String line) {
	int statusStart = line.indexOf(' ') + 1;

	if (statusStart < 1 || line.length() < statusStart + 3) {
		// Not a valid HTTP Status-Line
		log.warn(sm.getString("cgiServlet.runInvalidStatus", line));
		return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
	}

	String status = line.substring(statusStart, statusStart + 3);

	int statusCode;
	try {
		statusCode = Integer.parseInt(status);
	} catch (NumberFormatException nfe) {
		// Not a valid status code
		log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
		return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
	}

	return statusCode;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:30,代码来源:CGIServlet.java

示例4: getSCFromCGIStatusHeader

/**
 * Parses the CGI Status Header value and extracts the status code.
 *
 * @param value
 *            The CGI Status value of the form <code>
 *             digit digit digit SP reason-phrase</code>
 * @return The extracted status code or the code representing an
 *         internal error if a valid status code cannot be extracted.
 */
private int getSCFromCGIStatusHeader(String value) {
	if (value.length() < 3) {
		// Not a valid status value
		log.warn(sm.getString("cgiServlet.runInvalidStatus", value));
		return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
	}

	String status = value.substring(0, 3);

	int statusCode;
	try {
		statusCode = Integer.parseInt(status);
	} catch (NumberFormatException nfe) {
		// Not a valid status code
		log.warn(sm.getString("cgiServlet.runInvalidStatus", status));
		return HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
	}

	return statusCode;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:29,代码来源:CGIServlet.java

示例5: testCopyAncestor

/** Copying an ancestor to a descendant should fail */
public void testCopyAncestor() throws IOException {
    final String testPath = TEST_BASE_PATH + "/tcanc/" + System.currentTimeMillis();
    final String testRoot = testClient.createNode(HTTP_BASE_URL + testPath, null);
    final String parentPath = testPath + "/a/b";
    final String childPath = parentPath + "/child";
    
    final String parentUrl = testClient.createNode(HTTP_BASE_URL + parentPath, null);
    assertFalse("child node must not exist before copy", 
            getContent(parentUrl + ".2.json", CONTENT_TYPE_JSON).contains("child"));
    
    final List<NameValuePair> opt = new ArrayList<NameValuePair>();
    opt.add(new NameValuePair(SlingPostConstants.RP_OPERATION, SlingPostConstants.OPERATION_COPY));
    opt.add(new NameValuePair(SlingPostConstants.RP_DEST, childPath));
    
    final int expectedStatus = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    assertPostStatus(testRoot, expectedStatus, opt, "Expecting status " + expectedStatus);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:18,代码来源:PostServletCopyTest.java

示例6: postFileFolderActivity

private void postFileFolderActivity(
            String activityType,
            String siteId,
            String tenantDomain,
            String path,
            NodeRef parentNodeRef,
            FileInfo contentNodeInfo) throws WebDAVServerException
{
    String fileName = contentNodeInfo.getName();
    NodeRef nodeRef = contentNodeInfo.getNodeRef();
    
    try
    {
        poster.postFileFolderActivity(activityType, path, tenantDomain, siteId,
                               parentNodeRef, nodeRef, fileName,
                               appTool, Client.asType(ClientType.webdav),contentNodeInfo);
    }
    catch (AlfrescoRuntimeException are)
    {
        logger.error("Failed to post activity.", are);
        throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:ActivityPosterImpl.java

示例7: logAndReturnException

/**
    * Clean return of Exception in JSon format & log Exception.
    * @param request 
    * @param response
    * @param out
    * @param exception
    */
   public static void logAndReturnException(HttpServletRequest request,
    HttpServletResponse response, PrintWriter out, Exception exception) {

try {
    JsonErrorReturn jsonErrorReturn = new JsonErrorReturn(response,
    	HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
    	JsonErrorReturn.ERROR_ACEQL_ERROR, exception.getMessage(),
    	ExceptionUtils.getStackTrace(exception));

    out.println(jsonErrorReturn.build());
    LoggerUtil.log(request, exception);
} catch (Exception e) {
    // Should never happen
    e.printStackTrace();
}

   }
 
开发者ID:kawansoft,项目名称:aceql-http,代码行数:24,代码来源:ExceptionReturner.java

示例8: doPost

@Override
// A. It must be a POST request.
protected void doPost(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) throws ServletException, IOException {
    byte[] serializedSpeechletRequest = IOUtils.toByteArray(httpRequest.getInputStream());

    try {
        if (this.checkAmazonSignature) {
            // B. It must come from the Amazon Alexa cloud.
            SpeechletRequestSignatureVerifier.checkRequestSignature(serializedSpeechletRequest,
                    httpRequest.getHeader(Sdk.SIGNATURE_REQUEST_HEADER),
                    httpRequest.getHeader(Sdk.SIGNATURE_CERTIFICATE_CHAIN_URL_REQUEST_HEADER));
        }

        final SpeechletRequestEnvelope<?> requestEnvelope = SpeechletRequestEnvelope.fromJson(serializedSpeechletRequest);

        for (SpeechletRequestEnvelopeVerifier verifier : this.requestEnvelopeVerifiers) {
            if (!verifier.verify(requestEnvelope)) {
                throw new SpeechletRequestHandlerException(this.createExceptionMessage(verifier, requestEnvelope));
            }
        }

        HttpEntity<byte[]> requestEntity = new HttpEntity<>(serializedSpeechletRequest);
        ResponseEntity<SpeechletResponseEnvelope> speechletResponse = this.restTemplate.postForEntity(
                this.endpoint, requestEntity, SpeechletResponseEnvelope.class);
        if (speechletResponse.getStatusCode().is2xxSuccessful() && speechletResponse.hasBody()) {
            byte[] outputBytes = speechletResponse.getBody().toJsonBytes();
            httpResponse.setContentType("application/json");
            httpResponse.setStatus(speechletResponse.getStatusCodeValue());
            httpResponse.setContentLength(outputBytes.length);
            httpResponse.getOutputStream().write(outputBytes);
        } else {
            // Should never happen, cause all edge cases are already covered by actual exceptions thrown.
            httpResponse.sendError(speechletResponse.getStatusCodeValue(), "Unexpected error in proxy");
        }
    } catch (Exception e) {
        int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        if (BAD_REQUEST_EXCEPTION_TYPES.contains(e.getClass())) {
            statusCode = HttpServletResponse.SC_BAD_REQUEST;
        }
        this.log.error("Exception occurred in doPost, returning status code {}", statusCode, e);
        httpResponse.sendError(statusCode, e.getClass().getSimpleName() + ": " + e.getMessage());
    }
}
 
开发者ID:ewjmulder,项目名称:alexa-proxy,代码行数:43,代码来源:AlexaProxyServlet.java

示例9: testCopyAncestor

public void testCopyAncestor() throws IOException {
    final String testPath = TEST_BASE_PATH + "/AT_tcanc/" + System.currentTimeMillis();
    
    final List<NameValuePair> opt = new ArrayList<NameValuePair>();
    opt.add(new NameValuePair(testPath + "./@CopyFrom", "../"));
    
    final int expectedStatus = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
    assertPostStatus(HTTP_BASE_URL + testPath, expectedStatus, opt, "Expecting status " + expectedStatus);
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:9,代码来源:PostServletAtCopyTest.java

示例10: createACP

/**
 * Returns an ACP file containing the nodes represented by the given list of NodeRefs.
 * 
 * @param params The parameters for the ACP exporter
 * @param extension The file extenstion to use for the ACP file
 * @param keepFolderStructure Determines whether the folder structure is maintained for
 *        the content inside the ACP file
 * @return File object representing the created ACP
 */
protected File createACP(ExporterCrawlerParameters params, String extension, boolean keepFolderStructure)
{
    try
    {
        // generate temp file and folder name
        File dataFile = new File(GUID.generate());
        File contentDir = new File(GUID.generate());
        
        // setup export package handler
        File acpFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, "." + extension);
        ACPExportPackageHandler handler = new ACPExportPackageHandler(new FileOutputStream(acpFile), 
             dataFile, contentDir, this.mimetypeService);
        handler.setExportAsFolders(keepFolderStructure);
        handler.setNodeService(this.nodeService);

        // perform the actual export
        this.exporterService.exportView(handler, params, null);
        
        if (logger.isDebugEnabled())
            logger.debug("Created temporary archive: " + acpFile.getAbsolutePath());
        
        return acpFile;
    }
    catch (FileNotFoundException fnfe)
    {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 
                    "Failed to create archive", fnfe);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:38,代码来源:StreamACP.java

示例11: doFilter

@Override
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {
    if (!isGoodRequest(request)) {
        FailReason reason = (FailReason) request.getAttribute(
                Globals.PARAMETER_PARSE_FAILED_REASON_ATTR);

        int status;

        switch (reason) {
            case IO_ERROR:
                // Not the client's fault
                status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
                break;
            case POST_TOO_LARGE:
                status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE;
                break;
            case TOO_MANY_PARAMETERS:
                // 413/414 aren't really correct here since the request body
                // and/or URI could be well below any limits set. Use the
                // default.
            case UNKNOWN: // Assume the client is at fault
            // Various things that the client can get wrong that don't have
            // a specific status code so use the default.
            case INVALID_CONTENT_TYPE:
            case MULTIPART_CONFIG_INVALID:
            case NO_NAME:
            case REQUEST_BODY_INCOMPLETE:
            case URL_DECODING:
            case CLIENT_DISCONNECT:
                // Client is never going to see this so this is really just
                // for the access logs. The default is fine.
            default:
                // 400
                status = HttpServletResponse.SC_BAD_REQUEST;
                break;
        }

        ((HttpServletResponse) response).sendError(status);
        return;
    }
    chain.doFilter(request, response);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:43,代码来源:FailedRequestFilter.java

示例12: doFilter

@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
		throws IOException, ServletException {
	if (!isGoodRequest(request)) {
		FailReason reason = (FailReason) request.getAttribute(Globals.PARAMETER_PARSE_FAILED_REASON_ATTR);

		int status;

		switch (reason) {
		case IO_ERROR:
			// Not the client's fault
			status = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
			break;
		case POST_TOO_LARGE:
			status = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE;
			break;
		case TOO_MANY_PARAMETERS:
			// 413/414 aren't really correct here since the request body
			// and/or URI could be well below any limits set. Use the
			// default.
		case UNKNOWN: // Assume the client is at fault
			// Various things that the client can get wrong that don't have
			// a specific status code so use the default.
		case INVALID_CONTENT_TYPE:
		case MULTIPART_CONFIG_INVALID:
		case NO_NAME:
		case REQUEST_BODY_INCOMPLETE:
		case URL_DECODING:
		case CLIENT_DISCONNECT:
			// Client is never going to see this so this is really just
			// for the access logs. The default is fine.
		default:
			// 400
			status = HttpServletResponse.SC_BAD_REQUEST;
			break;
		}

		((HttpServletResponse) response).sendError(status);
		return;
	}
	chain.doFilter(request, response);
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:42,代码来源:FailedRequestFilter.java

示例13: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();
    
    // Current user
    String userID = AuthenticationUtil.getFullyAuthenticatedUser();
    if (userID == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_UNAUTHORIZED, "Web Script ["
                    + req.getServiceMatch().getWebScript().getDescription()
                    + "] requires user authentication.");
    }

    NodeRef nodeRefToBeRestored = parseRequestForNodeRef(req);
    if (nodeRefToBeRestored == null)
    {
        throw new WebScriptException(Status.STATUS_BAD_REQUEST, "nodeRef not recognised. Could not restore.");
    }
    
    // check if the current user has the permission to restore the node
    validatePermission(nodeRefToBeRestored, userID);
    
    RestoreNodeReport report = nodeArchiveService.restoreArchivedNode(nodeRefToBeRestored);

    // Handling of some error scenarios
    if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_ARCHIVE_NODE))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_PERMISSION))
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_DUPLICATE_CHILD_NODE_NAME))
    {
        throw new WebScriptException(HttpServletResponse.SC_CONFLICT, "Unable to restore archive node: " + nodeRefToBeRestored +". Duplicate child node name");
    }
    else if (report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INVALID_PARENT) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_INTEGRITY) ||
             report.getStatus().equals(RestoreNodeReport.RestoreStatus.FAILURE_OTHER))
    {
        throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to restore archive node: " + nodeRefToBeRestored);
    }
    
    model.put("restoreNodeReport", report);
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:48,代码来源:ArchivedNodePut.java

示例14: parseRequestHeaders

/**
 * Parse the request headers
 * 
 * @exception WebDAVServerException
 */
protected void parseRequestHeaders() throws WebDAVServerException
{
    // Get user Agent
    
    m_userAgent = m_request.getHeader(WebDAV.HEADER_USER_AGENT);

    // Get the depth

    parseDepthHeader();
    
    // According to the specification: "Values other than 0 or infinity MUST NOT be used with the Depth header on a LOCK method.".
    // The specification does not specify the error code for this case - so we use HttpServletResponse.SC_INTERNAL_SERVER_ERROR.
    if (m_depth != WebDAV.DEPTH_0 && m_depth != WebDAV.DEPTH_INFINITY)
    {
        throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
    
    // Parse Lock tokens and ETags, if any

    parseIfHeader();

    // Get the lock timeout value

    String strTimeout = m_request.getHeader(WebDAV.HEADER_TIMEOUT);

    // If the timeout header starts with anything other than Second
    // leave the timeout as the default

    if (strTimeout != null && strTimeout.startsWith(WebDAV.SECOND))
    {
        try
        {
            // Some clients send header as Second-180 Seconds so we need to
            // look for the space

            int idx = strTimeout.indexOf(" ");

            if (idx != -1)
            {
                // Get the bit after Second- and before the space

                strTimeout = strTimeout.substring(WebDAV.SECOND.length(), idx);
            }
            else
            {
                // The string must be in the correct format

                strTimeout = strTimeout.substring(WebDAV.SECOND.length());
            }
            m_timeoutDuration = Integer.parseInt(strTimeout);
        }
        catch (Exception e)
        {
            // Warn about the parse failure and leave the timeout as the
            // default

            logger.warn("Failed to parse Timeout header: " + strTimeout);
        }
    }

    // DEBUG

    if (logger.isDebugEnabled())
        logger.debug("Timeout=" + getLockTimeout() + ", depth=" + getDepth());
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:70,代码来源:LockMethod.java

示例15: postActivity

/**
 * Create an activity post.
 * 
 * @throws WebDAVServerException 
 */
protected void postActivity() throws WebDAVServerException
{
    WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService();
    if (!davService.activitiesEnabled())
    {
        // Don't post activities if this behaviour is disabled.
        return;
    }
    
    String path = getPath();
    String siteId = getSiteId();
    String tenantDomain = getTenantDomain();
    
    if (siteId.equals(WebDAVHelper.EMPTY_SITE_ID))
    {
        // There is not enough information to publish site activity.
        return;
    }
    
    FileInfo contentNodeInfo = null;
    try
    {
        contentNodeInfo = getNodeForPath(getRootNodeRef(), path);
        NodeRef nodeRef = contentNodeInfo.getNodeRef();
        // Don't post activity data for hidden files, resource forks etc.
        if (!getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_HIDDEN))
        {
            if (isCreated())
            {
                // file added
                activityPoster.postFileFolderAdded(siteId, tenantDomain, null, contentNodeInfo);
            }
            else
            {
                // file updated
                activityPoster.postFileFolderUpdated(siteId, tenantDomain, contentNodeInfo);
            }
        }
    }
    catch (FileNotFoundException error)
    {
        throw new WebDAVServerException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }        
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:49,代码来源:PutMethod.java


注:本文中的javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。