本文整理汇总了Java中org.mortbay.util.URIUtil类的典型用法代码示例。如果您正苦于以下问题:Java URIUtil类的具体用法?Java URIUtil怎么用?Java URIUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
URIUtil类属于org.mortbay.util包,在下文中一共展示了URIUtil类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: sendDirectory
import org.mortbay.util.URIUtil; //导入依赖的package包/类
protected void sendDirectory(HttpServletRequest request,
HttpServletResponse response, Resource resource, boolean parent)
throws IOException
{
byte[] data=null;
String base = URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH);
// Use customized getListHTML
String dir = getListHTML(resource, base, parent);
if (dir==null)
{
response.sendError(HttpServletResponse.SC_FORBIDDEN, "No directory");
return;
}
data=dir.getBytes("UTF-8");
response.setContentType("text/html; charset=UTF-8");
response.setContentLength(data.length);
response.getOutputStream().write(data);
}
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:19,代码来源:StaticServlet.java
示例2: handleRequest
import org.mortbay.util.URIUtil; //导入依赖的package包/类
protected void handleRequest() throws IOException
{
try
{
String info = URIUtil.canonicalPath(super._uri.getDecodedPath());
if (info==null) throw new HttpException(400);
info = info.substring(this.virtualContextPath.length());
super._request.setPathInfo(info);
HttpServletRequest request = super._request;
if( this.virtualContextPath != null )
{
request = new VirtualHttpServletRequestWrapper(super._request, this.virtualContextPath);
}
this.context.handle(info, request, _response, Handler.FORWARD);
}
catch (Exception e)
{
throw new IOException("Error handling request (" + e + ")!", e);
}
}
开发者ID:tolo,项目名称:JServer,代码行数:24,代码来源:VirtualHttpConnection.java
示例3: matchAndApply
import org.mortbay.util.URIUtil; //导入依赖的package包/类
public String matchAndApply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
{
Map.Entry<?,?> rewrite =_rewrite.getMatch(target);
if (rewrite!=null && rewrite.getValue()!=null)
{
target=URIUtil.addPaths(rewrite.getValue().toString(),
PathMap.pathInfo(rewrite.getKey().toString(),target));
return target;
}
return null;
}
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:15,代码来源:LegacyRule.java
示例4: apply
import org.mortbay.util.URIUtil; //导入依赖的package包/类
public String apply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
{
target = URIUtil.addPaths(_replacement, PathMap.pathInfo(_pattern,target));
return target;
}
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:6,代码来源:RewritePatternRule.java
示例5: getListHTML
import org.mortbay.util.URIUtil; //导入依赖的package包/类
public String getListHTML(Resource resource, String base, boolean parent)
throws IOException
{
base=URIUtil.canonicalPath(base);
if (base==null || !resource.isDirectory())
return null;
String[] ls = resource.list();
if (ls==null)
return null;
Arrays.sort(ls);
String decodedBase = URIUtil.decodePath(base);
String title = "Directory: "+deTag(decodedBase);
StringBuffer buf=new StringBuffer(4096);
buf.append("<HTML><HEAD><TITLE>");
buf.append(title);
buf.append("</TITLE></HEAD><BODY>\n<H1>");
buf.append(title);
buf.append("</H1>\n<TABLE BORDER=0>\n");
if (parent)
{
buf.append("<TR><TD><A HREF=\"");
buf.append(URIUtil.addPaths(base,"../"));
buf.append("\">Parent Directory</A></TD><TD></TD><TD></TD></TR>\n");
}
String defangedBase = defangURI(base);
DateFormat dfmt=DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
DateFormat.MEDIUM);
for (int i=0 ; i< ls.length ; i++)
{
Resource item = resource.addPath(ls[i]);
buf.append("\n<TR><TD><A HREF=\"");
String path=URIUtil.addPaths(defangedBase,URIUtil.encodePath(ls[i]));
buf.append(URIUtil.encodePath(ls[i]));
if (item.isDirectory() && !path.endsWith("/"))
buf.append(URIUtil.SLASH);
// URIUtil.encodePath(buf,path);
buf.append("\">");
buf.append(deTag(ls[i]));
buf.append(" ");
buf.append("</TD><TD ALIGN=right>");
buf.append(item.length());
buf.append(" bytes </TD><TD>");
buf.append(dfmt.format(new Date(item.lastModified())));
buf.append("</TD></TR>");
}
buf.append("</TABLE>\n");
buf.append("</BODY></HTML>\n");
return buf.toString();
}
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:60,代码来源:StaticServlet.java
示例6: handle
import org.mortbay.util.URIUtil; //导入依赖的package包/类
@Override
public void handle(HttpExchange exchange) throws IOException {
logger.trace(exchange.getRequestMethod() + "\n"
+ exchange.getRequestHeaders().entrySet() + "\n"
+ exchange.getResponseHeaders().entrySet());
String requestMethod = exchange.getRequestMethod();
if (requestMethod.equalsIgnoreCase("GET")) {
URI uri = exchange.getRequestURI();
String filename = uri.getPath().substring(1);
StringBuffer sb = new StringBuffer();
URIUtil.encodePath(sb, filename);
Map<String, Object> params
= (Map<String, Object>) exchange.getAttribute("parameters");
String response = null;
byte[] byteResponse = null;
// JSON tutorial
// http://code.google.com/p/json-simple/
if (params.containsKey("stats")) {
// response = handleStatsQuery(exchange);
} else if (params.containsKey("method")) {
String fn = (String) params.get("method");
if (fn.compareToIgnoreCase("get_speed_info") == 0) {
response = handleGetSpeedInfo(exchange);
}
} else if (params.containsKey("view")) {
String video = (String) params.get("view");
response = handleViewVideo(exchange, video);
} else if (params.containsKey("shutdown")) {
// Sent by the plugin when it is stopped by the browser.
// Allows the cleanup allocated resources.
handleShutdown(exchange);
} else if (params.containsKey("info")) {
//Sent to convey its current status to the plugin,
// which should be passed on to the user.
handleInfo(exchange);
} else {
// This is the fileserver part - swfobject.js, player.swf, *.htm, etc
String postfix
= filename.substring(filename.lastIndexOf(".") + 1, filename.length());
if (postfix.compareToIgnoreCase("swf") == 0
|| postfix.compareToIgnoreCase("ico") == 0) {
byteResponse = handleBinaryFile(exchange, sb.toString(), postfix);
} else {
response = handleTextFile(exchange, sb.toString(), postfix);
}
}
OutputStream responseBody = exchange.getResponseBody();
if (response != null) {
responseBody.write(response.getBytes(Charset.defaultCharset()));
} else if (byteResponse != null) {
responseBody.write(byteResponse);
} else {
logger.warn("Bad request issued by client: " + requestMethod);
throw new IllegalStateException("Something wrong.");
}
responseBody.flush();
responseBody.close();
}
}
开发者ID:jimdowling,项目名称:gvod,代码行数:67,代码来源:BrowserGuiHandler.java
示例7: handleViewVideo
import org.mortbay.util.URIUtil; //导入依赖的package包/类
private String handleViewVideo(HttpExchange exchange, String videoName)
throws IOException {
// return URL for .flv or .mp4 file to flashplayer
StringBuffer sb = new StringBuffer();
StringBuffer encodedVideoName = new StringBuffer();
URIUtil.encodePath(encodedVideoName, videoName);
String htmlFile = VodConfig.getTorrentDir()
+ File.separator + "www"
+ File.separator;
if (SwingMain.PLAYER == 0) {
htmlFile += JWPLAYER;
} else if (SwingMain.PLAYER == 1) {
htmlFile += FLOWPLAYER;
} else {
throw new IllegalStateException("Illegal parameter for media player.");
}
// Always stored the escaped (URI-encoded) video name
TorrentEntry torrentEntry = ActiveTorrents.getTorrentEntry(encodedVideoName.toString());
String width = Integer.toString(torrentEntry.getWidth());
String height = Integer.toString(torrentEntry.getHeight());
File f = new File(htmlFile);
boolean fileProb = false;
if (f.exists()) {
try {
ReadTextFileWithEncoding rf
= new ReadTextFileWithEncoding(f, "ISO8859_9");
String text = rf.getText();
text = text.replace(VIDEO_NAME, encodedVideoName.toString());
text = text.replace("640", width);
text = text.replace("320", height);
sb.append(text);
} catch (IOException e) {
fileProb = true;
}
} else {
fileProb = true;
}
if (fileProb) {
exchange.sendResponseHeaders(404 /* http file not found*/, 0);
} else {
exchange.sendResponseHeaders(200 /* http ok code */, 0);
}
return sb.toString();
}
开发者ID:jimdowling,项目名称:gvod,代码行数:53,代码来源:BrowserGuiHandler.java
注:本文中的org.mortbay.util.URIUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论