本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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()));
}
}
示例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()));
}
}
示例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()));
}
}