• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java URIUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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("&nbsp;");
        buf.append("</TD><TD ALIGN=right>");
        buf.append(item.length());
        buf.append(" bytes&nbsp;</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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TransactionRolledBackRuntimeException类代码示例发布时间:2022-05-22
下一篇:
Java XulPromptBox类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap