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


Java HttpServletResponse.SC_BAD_REQUEST属性代码示例

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


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

示例1: doGet

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    // Only set the status on the first call (the dispatch will trigger
    // another call to this Servlet)
    if (resp.getStatus() != HttpServletResponse.SC_BAD_REQUEST) {
        resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
        AsyncContext ac = req.startAsync();
        ac.dispatch();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:11,代码来源:TestErrorReportValve.java

示例2: getState

/**
 * Gets the specified {@link WorkflowTaskState}, null if not requested
 * 
 * @param req WebScriptRequest
 * @return WorkflowTaskState
 */
private WorkflowTaskState getState(WebScriptRequest req)
{
    String stateName = req.getParameter(PARAM_STATE);
    if (stateName != null)
    {
        try
        {
            return WorkflowTaskState.valueOf(stateName.toUpperCase());
        }
        catch (IllegalArgumentException e)
        {
            String msg = "Unrecognised State parameter: " + stateName;
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
        }
    }
    
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:TaskInstancesGet.java

示例3: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    NodeRef nodeRef = parseRequestForNodeRef(req);
    String ratingSchemeName = parseRequestForScheme(req);
    
    Rating deletedRating = ratingService.removeRatingByCurrentUser(nodeRef, ratingSchemeName);
    if (deletedRating == null)
    {
        // There was no rating in the specified scheme to delete.
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Unable to delete non-existent rating: "
                + ratingSchemeName + " from " + nodeRef.toString());
    }
    
    model.put(NODE_REF, nodeRef.toString());
    model.put(AVERAGE_RATING, ratingService.getAverageRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_TOTAL, ratingService.getTotalRating(nodeRef, ratingSchemeName));
    model.put(RATINGS_COUNT, ratingService.getRatingsCount(nodeRef, ratingSchemeName));
  
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:RatingDelete.java

示例4: getState

/**
 * Gets the specified {@link WorkflowState}, null if not requested.
 * 
 * @param req The WebScript request
 * @return The workflow state or null if not requested
 */
private WorkflowState getState(WebScriptRequest req)
{
    String stateName = req.getParameter(PARAM_STATE);
    if (stateName != null)
    {
        try
        {
            return WorkflowState.valueOf(stateName.toUpperCase());
        }
        catch (IllegalArgumentException e)
        {
            String msg = "Unrecognised State parameter: " + stateName;
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
        }
    }
    
    return null;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:WorkflowInstancesGet.java

示例5: executeImpl

protected void executeImpl(NodeRef nodeRef, Map<String, String> templateVars, WebScriptRequest req, WebScriptResponse res, Map<String, Object> model) throws IOException
{
    // render content
       QName propertyQName = ContentModel.PROP_CONTENT;
       String contentPart = templateVars.get("property");
       if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
       {
           if (contentPart.length() < 2)
           {
               throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
           }
           String propertyName = contentPart.substring(1);
           if (propertyName.length() > 0)
           {
               propertyQName = QName.createQName(propertyName, namespaceService);
           }
       }
       
       // determine attachment
       boolean attach = Boolean.valueOf(req.getParameter("a"));
       
       // Stream the content
       streamContentLocal(req, res, nodeRef, attach, propertyQName, model);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:QuickShareContentGet.java

示例6: getIntParameter

private int getIntParameter(WebScriptRequest req, String paramName, int defaultValue)
{
    String paramString = req.getParameter(paramName);

    if (paramString != null)
    {
        try
        {
            int param = Integer.valueOf(paramString);

            if (param >= 0)
            {
                return param;
            }
        }
        catch (NumberFormatException e)
        {
            throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
        }
    }

    return defaultValue;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:SiteAdminSitesGet.java

示例7: setStatus

/**
 * Behaviour depends on the status code.
 *
 * Status < 400 - Calls setStatus. Returns false. CGI servlet will provide
 * the response body. Status >= 400 - Calls sendError(status), returns true.
 * Standard error page mechanism will provide the response body.
 */
private boolean setStatus(HttpServletResponse response, int status) throws IOException {
	if (status >= HttpServletResponse.SC_BAD_REQUEST) {
		response.sendError(status);
		return true;
	} else {
		response.setStatus(status);
		return false;
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:16,代码来源:CGIServlet.java

示例8: parseRequestHeaders

/**
 * Parse the request headers
 * 
 * @exception WebDAVServerException
 */
protected void parseRequestHeaders() throws WebDAVServerException
{
    // Get the lock token, if any
    String strLockTokenHeader = m_request.getHeader(WebDAV.HEADER_LOCK_TOKEN);

    // DEBUG
    if (logger.isDebugEnabled())
        logger.debug("Parsing Lock-Token header: " + strLockTokenHeader);

    // Validate the lock token
    if (strLockTokenHeader != null)
    {
        if (!(strLockTokenHeader.startsWith("<") && strLockTokenHeader.endsWith(">")))
        {
            // ALF-13904: Header isn't correctly enclosed in < and > characters. Try correcting this
            // to allow for Windows 7 + OpenOffice.org bug.
            strLockTokenHeader = "<" + strLockTokenHeader + ">";
        }
        if (strLockTokenHeader.startsWith("<" + WebDAV.OPAQUE_LOCK_TOKEN) && strLockTokenHeader.endsWith(">"))
        {
            try
            {
                m_strLockToken = strLockTokenHeader.substring(
                        WebDAV.OPAQUE_LOCK_TOKEN.length() + 1,
                        strLockTokenHeader.length() - 1);
            }
            catch (IndexOutOfBoundsException e)
            {
                logger.warn("Failed to parse If header: " + strLockTokenHeader);
         }
     }
    }
    // If there is no token this is a bad request so send an error back
    if (m_strLockToken == null)
    {
        throw new WebDAVServerException(HttpServletResponse.SC_BAD_REQUEST);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:43,代码来源:UnlockMethod.java

示例9: testCommitOnComplete

@Test
public void testCommitOnComplete() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    AsyncStatusServlet asyncStatusServlet =
        new AsyncStatusServlet(HttpServletResponse.SC_BAD_REQUEST);
    Wrapper wrapper =
        Tomcat.addServlet(ctx, "asyncStatusServlet", asyncStatusServlet);
    wrapper.setAsyncSupported(true);
    ctx.addServletMapping("/asyncStatusServlet", "asyncStatusServlet");

    TesterAccessLogValve alv = new TesterAccessLogValve();
    ctx.getPipeline().addValve(alv);

    tomcat.start();

    StringBuilder url = new StringBuilder(48);
    url.append("http://localhost:");
    url.append(getPort());
    url.append("/asyncStatusServlet");

    int rc = getUrl(url.toString(), new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_BAD_REQUEST, rc);

    // Without this test may complete before access log has a chance to log
    // the request
    Thread.sleep(REQUEST_TIME);

    // Check the access log
    alv.validateAccessLog(1, HttpServletResponse.SC_BAD_REQUEST, 0,
            REQUEST_TIME);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:TestAsyncContextImpl.java

示例10: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
    if (nodeRef == null)
    {
        String msg = "A valid NodeRef must be specified!";
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
    }
    
    try
    {
        QuickShareDTO dto = quickShareService.shareContent(nodeRef);
        
        Map<String, Object> model = new HashMap<String, Object>(1);
        model.put("sharedDTO", dto);
        return model;
    }
    catch (InvalidNodeRefException inre)
    {
    	throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:30,代码来源:ShareContentPost.java

示例11: validateFilterID

protected void validateFilterID(String filterID)
{
    Matcher matcher = FILTER_ID_PATTERN.matcher(filterID);
    if (matcher.find())
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST,
                    "Invalid Filter Id. The characters \" * \\ < > ? / : | are not allowed. The Filter Id cannot end with a dot.");
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:9,代码来源:AbstractSolrFacetConfigAdminWebScript.java

示例12: finishResponse

/**
 * Perform whatever actions are required to flush and close the output
 * stream or writer, in a single operation.
 *
 * @exception IOException if an input/output error occurs
 */
public void finishResponse() throws IOException {

    if (getStatus() < HttpServletResponse.SC_BAD_REQUEST) {
        if ((!isStreamInitialized()) && (getContentLength() == -1)
            && (getStatus() >= 200)
            && (getStatus() != SC_NOT_MODIFIED)
            && (getStatus() != SC_NO_CONTENT))
            setContentLength(0);
    } else {
        setHeader("Connection", "close");
    }
    super.finishResponse();

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:20,代码来源:HttpResponseImpl.java

示例13: setStatus

/**
 * Behaviour depends on the status code.
 *
 * Status < 400  - Calls setStatus. Returns false. CGI servlet will provide
 *                 the response body.
 * Status >= 400 - Calls sendError(status), returns true. Standard error
 *                 page mechanism will provide the response body.
 */
private boolean setStatus(HttpServletResponse response, int status) throws IOException {
    if (status >= HttpServletResponse.SC_BAD_REQUEST) {
        response.sendError(status);
        return true;
    } else {
        response.setStatus(status);
        return false;
    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:CGIServlet.java

示例14: executeImpl

@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final NodeRef nodeRef = WebScriptUtil.getNodeRef(params);
    if (nodeRef == null)
    {
        String msg = "A valid NodeRef must be specified!";
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, msg);
    }
    
    try
    {
        Map<String, Object> model = quickShareService.getMetaData(nodeRef);
        
        if (logger.isDebugEnabled())
        {
            logger.debug("Retrieved limited metadata: "+nodeRef+" ["+model+"]");
        }
        
        return model;
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find node: "+inre.getNodeRef());
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find nodeRef: "+inre.getNodeRef());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:29,代码来源:MetaDataGet.java

示例15: patchProperties

protected void patchProperties(FileInfo nodeInfo, String path) throws WebDAVServerException
{
    failedProperty = null;
    for (PropertyAction action : m_propertyActions)
    {
        if (action.getProperty().isProtected())
        {
            failedProperty = action.getProperty();
            break;
        }
    }

    Map<QName, String> deadProperties = null;
    for (PropertyAction propertyAction : m_propertyActions)
    {
        int statusCode;
        String statusCodeDescription;
        WebDAVProperty property = propertyAction.getProperty();

        if (failedProperty == null)
        {
            PropertyDefinition propDef = getDAVHelper().getDictionaryService().getProperty(property.createQName());
            
            boolean deadProperty = propDef == null || (!propDef.getContainerClass().isAspect() && !getDAVHelper().getDictionaryService().isSubClass(getNodeService().getType(nodeInfo.getNodeRef()), 
                    propDef.getContainerClass().getName()));
            
            if (deadProperty && deadProperties == null)
            {
                deadProperties = loadDeadProperties(nodeInfo.getNodeRef());
            }

            if (PropertyAction.SET == propertyAction.getAction())
            {
                if (deadProperty)
                {
                    deadProperties.put(property.createQName(), property.getValue());
                }
                else
                {
                    getNodeService().setProperty(nodeInfo.getNodeRef(), property.createQName(), property.getValue());
                }
            }
            else if (PropertyAction.REMOVE == propertyAction.getAction())
            {
                if (deadProperty)
                {
                    deadProperties.remove(property.createQName());
                }
                else
                {
                    getNodeService().removeProperty(nodeInfo.getNodeRef(), property.createQName());
                }
            }
            else
            {
                throw new WebDAVServerException(HttpServletResponse.SC_BAD_REQUEST);
            }
            statusCode = HttpServletResponse.SC_OK;
            statusCodeDescription = WebDAV.SC_OK_DESC;
        }
        else if (failedProperty == property)
        {
            statusCode = HttpServletResponse.SC_FORBIDDEN;
            statusCodeDescription = WebDAV.SC_FORBIDDEN_DESC;
        }
        else
        {
            statusCode = WebDAV.WEBDAV_SC_FAILED_DEPENDENCY;
            statusCodeDescription = WebDAV.WEBDAV_SC_FAILED_DEPENDENCY_DESC;
        }

        propertyAction.setResult(statusCode, statusCodeDescription);
    }
    if (deadProperties != null)
    {
        persistDeadProperties(nodeInfo.getNodeRef(), deadProperties);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:78,代码来源:PropPatchMethod.java


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