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


Java RequestUtil类代码示例

本文整理汇总了Java中org.apache.catalina.util.RequestUtil的典型用法代码示例。如果您正苦于以下问题:Java RequestUtil类的具体用法?Java RequestUtil怎么用?Java RequestUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: validateContextName

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
protected static boolean validateContextName(ContextName cn,
        PrintWriter writer, StringManager sm) {
    
    // ContextName should be non-null with a path that is empty or starts
    // with /
    if (cn != null &&
            (cn.getPath().startsWith("/") || cn.getPath().equals(""))) {
        return true;
    }
    
    String path = null;
    if (cn != null) {
        path = RequestUtil.filter(cn.getPath());
    }
    writer.println(sm.getString("managerServlet.invalidPath", path));
    return false;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:ManagerServlet.java

示例2: getSessionsForPath

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
protected Session[] getSessionsForPath(String path) {
    if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
        throw new IllegalArgumentException(sm.getString("managerServlet.invalidPath",
                                    RequestUtil.filter(path)));
    }
    String displayPath = path;
    if( path.equals("/") )
        path = "";
    Context context = (Context) host.findChild(path);
    if (null == context) {
        throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
                                    RequestUtil.filter(displayPath)));
    }
    Session[] sessions = context.getManager().findSessions();
    return sessions;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HTMLManagerServlet.java

示例3: getSessionForPathAndId

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
protected Session getSessionForPathAndId(String path, String id) throws IOException {
    if ((path == null) || (!path.startsWith("/") && path.equals(""))) {
        throw new IllegalArgumentException(sm.getString("managerServlet.invalidPath",
                                    RequestUtil.filter(path)));
    }
    String displayPath = path;
    if( path.equals("/") )
        path = "";
    Context context = (Context) host.findChild(path);
    if (null == context) {
        throw new IllegalArgumentException(sm.getString("managerServlet.noContext",
                                    RequestUtil.filter(displayPath)));
    }
    Session session = context.getManager().findSession(id);
    return session;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:HTMLManagerServlet.java

示例4: getResourceAsStream

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Return the requested resource as an <code>InputStream</code>.  The
 * path must be specified according to the rules described under
 * <code>getResource</code>.  If no such resource can be identified,
 * return <code>null</code>.
 *
 * @param path The path to the desired resource.
 */
public InputStream getResourceAsStream(String path) {

    if (path == null || (Globals.STRICT_SERVLET_COMPLIANCE && !path.startsWith("/")))
        return (null);

    path = RequestUtil.normalize(path);
    if (path == null)
        return (null);

    DirContext resources = context.getResources();
    if (resources != null) {
        try {
            Object resource = resources.lookup(path);
            if (resource instanceof Resource)
                return (((Resource) resource).streamContent());
        } catch (Exception e) {
        }
    }
    return (null);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ApplicationContext.java

示例5: getResourcePaths

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Return a Set containing the resource paths of resources member of the
 * specified collection. Each path will be a String starting with
 * a "/" character. The returned set is immutable.
 *
 * @param path Collection path
 */
public Set getResourcePaths(String path) {

    // Validate the path argument
    if (path == null) {
        return null;
    }
    if (!path.startsWith("/")) {
        throw new IllegalArgumentException
            (sm.getString("applicationContext.resourcePaths.iae", path));
    }

    path = RequestUtil.normalize(path);
    if (path == null)
        return (null);

    DirContext resources = context.getResources();
    if (resources != null) {
        return (getResourcePathsInternal(resources, path));
    }
    return (null);

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:ApplicationContext.java

示例6: setContentType

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Set the content type for this Response.
 *
 * @param type The new content type
 */
public void setContentType(String type) {

    if (isCommitted())
        return;

    if (included)
        return;     // Ignore any call from an included servlet

    this.contentType = type;
    if (type.indexOf(';') >= 0) {
        encoding = RequestUtil.parseCharacterEncoding(type);
        if (encoding == null)
            encoding = "ISO-8859-1";
    } else {
        if (encoding != null)
            this.contentType = type + ";charset=" + encoding;
    }

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

示例7: normalize

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
    * Return a context-relative path, beginning with a "/", that represents
    * the canonical version of the specified path after ".." and "." elements
    * are resolved out.  If the specified path attempts to go outside the
    * boundaries of the current context (i.e. too many ".." path elements
    * are present), return <code>null</code> instead.
    *
    * This normalize should be the same as DefaultServlet.normalize, which is almost the same
    * ( see source code below ) as RequestUtil.normalize.  Do we need all this duplication?
    *
    * @param path Path to be normalized
    */
   public static String normalize(String path) {
       if (path == null)
           return null;

String normalized = path;

//Why doesn't RequestUtil do this??

       // Normalize the slashes and add leading slash if necessary
       if ( normalized.indexOf('\\') >= 0 )
           normalized = normalized.replace( '\\', '/' );

normalized = RequestUtil.normalize( path );
return normalized;
   }
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:28,代码来源:SSIServletRequestUtil.java

示例8: addServletMapping

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Add a new servlet mapping, replacing any existing mapping for
 * the specified pattern.
 *
 * @param pattern URL pattern to be mapped
 * @param name Name of the corresponding servlet to execute
 *
 * @exception IllegalArgumentException if the specified servlet name
 *  is not known to this Context
 */
public void addServletMapping(String pattern, String name) {

    // Validate the proposed mapping
    if (findChild(name) == null)
        throw new IllegalArgumentException
            (sm.getString("standardContext.servletMap.name", name));
    pattern = adjustURLPattern(RequestUtil.URLDecode(pattern));
    if (!validateURLPattern(pattern))
        throw new IllegalArgumentException
            (sm.getString("standardContext.servletMap.pattern", pattern));

    // Add this mapping to our registered set
    synchronized (servletMappings) {
        servletMappings.put(pattern, name);
    }
    fireContainerEvent("addServletMapping", pattern);

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

示例9: mergeParameters

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Merge the parameters from the saved query parameter string (if any), and
 * the parameters already present on this request (if any), such that the
 * parameter values from the query string show up first if there are
 * duplicate parameter names.
 */
private void mergeParameters() {

    if ((queryParamString == null) || (queryParamString.length() < 1))
        return;

    HashMap<String, String[]> queryParameters = new HashMap<String, String[]>();
    String encoding = getCharacterEncoding();
    if (encoding == null)
        encoding = "ISO-8859-1";
    RequestUtil.parseParameters(queryParameters, queryParamString,
            encoding);
    Iterator<String> keys = parameters.keySet().iterator();
    while (keys.hasNext()) {
        String key = keys.next();
        Object value = queryParameters.get(key);
        if (value == null) {
            queryParameters.put(key, parameters.get(key));
            continue;
        }
        queryParameters.put
            (key, mergeValues(value, parameters.get(key)));
    }
    parameters = queryParameters;

}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:32,代码来源:ApplicationHttpRequest.java

示例10: parseStreamParameters

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Read all parameters directly from the input stream. Necessary because parameters are not mapped to the 
 * HttpRequest.getParameter api on PUT requests
 * @param req
 * @param params
 */
private void parseStreamParameters(HttpServletRequest req, Map<String, List<String>> params) {

	try {
		String content = this.convertStreamToString(req.getInputStream());
		if( content != null && content.length() >= 1 ){
			Map<String, String[]> ps = new HashMap<String, String[]>();
			RequestUtil.parseParameters(ps, content, "UTF-8");
			for (String key : ps.keySet()) {
				List<String> param = new ArrayList<String>();
				for(String value : ps.get(key)) {
					param.add(value);
				}
				params.put(key, param);
			}
		}
	} catch (IOException e) {
		throw new InputException(e);
	}
}
 
开发者ID:iotsap,项目名称:FiWare-Template-Handler,代码行数:26,代码来源:ParseParametersFilter.java

示例11: getResourcePaths

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Return a Set containing the resource paths of resources member of the
 * specified collection. Each path will be a String starting with
 * a "/" character. The returned set is immutable.
 *
 * @param path Collection path
 */
@Override
public Set<String> getResourcePaths(String path) {

    // Validate the path argument
    if (path == null) {
        return null;
    }
    if (!path.startsWith("/")) {
        throw new IllegalArgumentException
            (sm.getString("applicationContext.resourcePaths.iae", path));
    }

    String normalizedPath = RequestUtil.normalize(path);
    if (normalizedPath == null)
        return (null);

    DirContext resources = context.getResources();
    if (resources != null) {
        return (getResourcePathsInternal(resources, normalizedPath));
    }
    return (null);

}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:31,代码来源:ApplicationContext.java

示例12: getSessionsForName

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
protected List<Session> getSessionsForName(ContextName cn,
        StringManager smClient) {
    if ((cn == null) || !(cn.getPath().startsWith("/") ||
            cn.getPath().equals(""))) {
        String path = null;
        if (cn != null) {
            path = cn.getPath();
        }
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.invalidPath",
                RequestUtil.filter(path)));
    }

    Context ctxt = (Context) host.findChild(cn.getName());
    if (null == ctxt) {
        throw new IllegalArgumentException(smClient.getString(
                "managerServlet.noContext",
                RequestUtil.filter(cn.getDisplayName())));
    }
    Manager manager = ctxt.getManager();
    List<Session> sessions = new ArrayList<Session>();
    sessions.addAll(Arrays.asList(manager.findSessions()));
    if (manager instanceof DistributedManager && showProxySessions) {
        // Add dummy proxy sessions
        Set<String> sessionIds =
            ((DistributedManager) manager).getSessionIdsFull();
        // Remove active (primary and backup) session IDs from full list
        for (Session session : sessions) {
            sessionIds.remove(session.getId());
        }
        // Left with just proxy sessions - add them
        for (String sessionId : sessionIds) {
            sessions.add(new DummyProxySession(sessionId));
        }
    }
    return sessions;
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:38,代码来源:HTMLManagerServlet.java

示例13: reload

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Reload the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be restarted
 */
protected void reload(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("restart: Reloading web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    RequestUtil.filter(cn.getDisplayName())));
            return;
        }
        // It isn't possible for the manager to reload itself
        if (context.getName().equals(this.context.getName())) {
            writer.println(smClient.getString("managerServlet.noSelf"));
            return;
        }
        context.reload();
        writer.println(smClient.getString("managerServlet.reloaded",
                cn.getDisplayName()));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.reload[" + cn.getDisplayName() + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

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

示例14: start

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Start the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be started
 */
protected void start(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("start: Starting web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext", 
                    RequestUtil.filter(displayPath)));
            return;
        }
        context.start();
        if (context.getState().isAvailable())
            writer.println(smClient.getString("managerServlet.started",
                    displayPath));
        else
            writer.println(smClient.getString("managerServlet.startFailed",
                    displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        getServletContext().log(sm.getString("managerServlet.startFailed",
                displayPath), t);
        writer.println(smClient.getString("managerServlet.startFailed",
                displayPath));
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

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

示例15: stop

import org.apache.catalina.util.RequestUtil; //导入依赖的package包/类
/**
 * Stop the web application at the specified context path.
 *
 * @param writer Writer to render to
 * @param cn Name of the application to be stopped
 */
protected void stop(PrintWriter writer, ContextName cn,
        StringManager smClient) {

    if (debug >= 1)
        log("stop: Stopping web application '" + cn + "'");

    if (!validateContextName(cn, writer, smClient)) {
        return;
    }

    String displayPath = cn.getDisplayName();

    try {
        Context context = (Context) host.findChild(cn.getName());
        if (context == null) {
            writer.println(smClient.getString("managerServlet.noContext",
                    RequestUtil.filter(displayPath)));
            return;
        }
        // It isn't possible for the manager to stop itself
        if (context.getName().equals(this.context.getName())) {
            writer.println(smClient.getString("managerServlet.noSelf"));
            return;
        }
        context.stop();
        writer.println(smClient.getString(
                "managerServlet.stopped", displayPath));
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        log("ManagerServlet.stop[" + displayPath + "]", t);
        writer.println(smClient.getString("managerServlet.exception",
                t.toString()));
    }

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


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