Examples of HtmlGenerator


Examples of org.w3c.jigsaw.html.HtmlGenerator

      e.setProxyAuthenticate(new_c);
  } else {
      e = request.makeReply(HTTP.UNAUTHORIZED);
      e.setWWWAuthenticate (new_c);
  }
  HtmlGenerator g = new HtmlGenerator("Unauthorized");
  g.append ("<h1>Unauthorized access</h1>"
      + "<p>You are denied access to this resource.");
  e.setStream(g);
  throw new HTTPException (e);
    }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

    }
      } catch (Exception ex) {
    ex.printStackTrace();
      }
      reply.setLocation(loc);
      HtmlGenerator g = new HtmlGenerator("Moved");
      g.append("<P>This resources has moved, click on the link if your"
         + " browser doesn't support automatic redirection<BR>"+
         "<A HREF=\""+loc.toExternalForm()+"\">"+
         loc.toExternalForm()+"</A>");
      reply.setStream(g);
      return reply ;
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

      } else if (cal.after(c_b)) {
    reply = request.makeReply(HTTP.SERVICE_UNAVAILABLE);
      }
  }
  if (reply != null) {
      HtmlGenerator g = new HtmlGenerator("Service Unavailable");
      g.append("You may retry after the delay or the date given");
      reply.setStream(g);
  }
  return reply;
    }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

         int status,
         String title,
         String msg)
    {
  Reply error = request.makeReply(status);
  HtmlGenerator g = CvsFrame.getHtmlGenerator(title);
  g.append("<span class=\"title\">",title,"</span>\n");
  g.append("<p>",msg);
  error.setStream(g);
  return error;
    }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

  return Integer.toString((int) p)+"%";
    }

    public Reply get(Request request) {
  Reply         r = createDefaultReply(request, HTTP.OK);
  HtmlGenerator g = new HtmlGenerator("Proxy statistics");
  int           c = proxy.reqcount+proxy.reqerred;
 
  if ( c == 0 )
      c = 1;
  g.addMeta("Refresh", "30");
  proxy.addStyleSheet(g);
  g.append("<h1>Proxy statistics</h1>");
  g.append("<p>The proxy was last started at: <em>"
                 + startdate
                 + "</em>");
  g.append("<p><table align=\"center\" border=\"1\"");
  g.append("<tr><th colspan=\"3\">Counter<th>count<th>percentage");
  // The total number of hits to the proxy:
  g.append("<tr><td colspan=\"3\">Total number of handled requests");
  g.append("<td align=center>", Integer.toString(c));
  g.append("<td align=center>", percentage(c, c));
  // The total number of errors:
  g.append("<tr><td width=50><td colspan=\"2\">Erred requests");
  g.append("<td align=center>", Integer.toString(proxy.reqerred));
  g.append("<td align=center>", percentage(proxy.reqerred, c));
  // The total number of ICP redirects:
  g.append("<tr><td width=50><td colspan=\"2\">ICP redirects");
  g.append("<td align=center>", Integer.toString(proxy.cache_icps));
  g.append("<td align=center>", percentage(proxy.cache_icps, c));
  // The total number of no-cache:
  g.append("<tr><td width=50><td colspan=\"2\">Non cacheable");
  g.append("<td align=center>", Integer.toString(proxy.cache_nocache));
  g.append("<td align=center>", percentage(proxy.cache_nocache, c));
  // Cache accesses:
  int cached = (proxy.cache_hits +
          proxy.cache_misses +
          proxy.cache_revalidations +
          proxy.cache_retrievals);
  g.append("<tr><td width=50><td colspan=\"2\">Cache Accesses");
  g.append("<td align=center>", Integer.toString(cached));
  g.append("<td align=center>", percentage(cached, c));
  // Hits (served by cache)
  g.append("<tr><td width=50><td width=50><td>Hits (served by cache)");
  g.append("<td align=center>", Integer.toString(proxy.cache_hits));
  g.append("<td align=center>", percentage(proxy.cache_hits, c));
  // Hits (revalidations)
  g.append("<tr><td width=50><td width=50><td>Hits (revalidations)");
  g.append("<td align=center>"
     , Integer.toString(proxy.cache_revalidations));
  g.append("<td align=center>"
     , percentage(proxy.cache_revalidations, c));
  // Misses (no cache entry)
  g.append("<tr><td width=50><td width=50><td>Misses (no entry)");
  g.append("<td align=center>", Integer.toString(proxy.cache_misses));
  g.append("<td align=center>", percentage(proxy.cache_misses, c));
  // Misses (retrievals)
  g.append("<tr><td width=50><td width=50><td>Misses (retrievals)");
  g.append("<td align=center>",Integer.toString(proxy.cache_retrievals));
  g.append("<td align=center>", percentage(proxy.cache_retrievals, c));
  g.append("</table>");
  // Some goodies:
  g.append("<hr>Generated by <i>"
     , proxy.getServer().getURL().toExternalForm());
  r.setStream(g);
  r.addPragma("no-cache");
  r.setNoCache();
  return r;
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

    || (dirResource.getLastModified() > listing_stamp)
    || (getLastModified() > listing_stamp)) {
   
    Enumeration e = dirResource.enumerateResourceIdentifiers() ;
    Vector        resources = Sorter.sortStringEnumeration(e) ;
    HtmlGenerator g = new HtmlGenerator("Directory listing of "+
              dirResource.getIdentifier());
    // Add style link
    addStyleSheet(g);
    g.append("<h1>Directory listing of ",
       dirResource.getIdentifier(),
       "</h1>");
    // Link to the parent, when possible:
    if ( dirResource.getParent() != null )
        g.append("<p><a href=\"..\">Parent</a><br>");
    g.append("\n<form method=\"POST\" action=\""+request.getURL()
       +"\">\n");
    String listername = getResource().getIdentifier();
    // List the children:
    g.append("<table border=\"0\">\n");

    ResourceReference rr       = null;
    FramedResource    resource = null;
    String            name     = null;
    //ugly hack to put CVS link first
    rr = dirResource.lookup("CVS");
    if (rr != null) {
        g.append(getResourceLine(rr, "CVS", false));
    }
    boolean even = true;
    for (int i = 0 ; i < resources.size() ; i++) {
        name = (String) resources.elementAt(i);
        if ( name.equals(listername) || name.equals("CVS"))
      continue;
        rr = dirResource.lookup(name);
        g.append(getResourceLine(rr, name, even));
        even = !even;
    }
    g.append("</table>\n");
    g.append("<P><INPUT TYPE=\"SUBMIT\" NAME=\"SUBMIT\" VALUE=\""+
       "Delete file from  publishing space\"></FORM>\n");
    g.close() ;
    listing_stamp = getLastModified() ;
    listing       = g ;
      } else if ( checkIfModifiedSince(request) == COND_FAILED ) {
    // Is it an IMS request ?
    return createDefaultReply(request, HTTP.NOT_MODIFIED) ;
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

      http_class = null;
    }

    Enumeration   e     = cresource.enumerateResourceIdentifiers();
    Vector    resources = Sorter.sortStringEnumeration(e) ;
    HtmlGenerator g     =
          new HtmlGenerator("Index of "+cresource.getIdentifier());
    // Add style link
    addStyleSheet(g);
    g.append("<h1>"+cresource.getIdentifier()+"</h1>");
    // Link to the parent, when possible:
    if ( cresource.getParent() != null ) {
        g.append("<p><a href=\"..\">Parent</a><br>");
    }
      // List the children:
    for (int i = 0 ; i < resources.size() ; i++) {
        String            name = (String) resources.elementAt(i);
        ResourceReference rr   = null;
        long              size = -1;
        rr = cresource.lookup(name);
        FramedResource resource = null;
        if (rr != null) {
      try {
          resource = (FramedResource) rr.unsafeLock();
          // remove manually deleted FileResources
          if( resource instanceof FileResource ) {
              FileResource fr = (FileResource)resource;
        if( !fr.getFile().exists() ) {
            try {
          fr.delete();
            } catch (MultipleLockException ex) {};
            continue;
        } else {
          size = fr.getFile().length();
        }
          }
          HTTPFrame itsframe = null;
          if (http_class != null)
        itsframe =
            (HTTPFrame) resource.getFrame(http_class);
          if (itsframe != null) {
        // Icon first, if available
        String icon = itsframe.getIcon() ;
        if ( icon != null ) {
            g.append("<img src=\""+
               getIconDirectory() +"/"+ icon+
               "\" alt=\"" + icon + "\">");
        }
        // Resource's name with link:
        if (resource instanceof ContainerInterface) {
            g.append("<a href=\""
               , URLEncoder.encode(name)
               , "/\">"+name+"</a>");
        } else {
            g.append("<a href=\""
               , URLEncoder.encode(name)
               , "\">"+name+"</a>");
        }
        // resource's title, if any:
        String title = itsframe.getTitle();
        if ( title != null ) {
            g.append(" "+title);
        }
        //size (if any)
        if (size != -1) {
            String s = null;
            if (size > 1023) {
          s = " ["+(size/1024)+" KB]";
            } else {
          s = " ["+size+" bytes]";
            }
            g.append(s);
        }
        g.append("<br>\n");
          } else {
        // Resource's name with link:
        g.append(name+
           " (<i>Not available via HTTP.</i>)");
        g.append("<br>\n");
          }
      } catch (InvalidResourceException ex) {
          g.append(name+
          " cannot be loaded (server misconfigured)");
          g.append("<br>\n");
          continue;
      } finally {
          rr.unlock();
      }
        }
    }
    g.close() ;
    listing_stamp = getLastModified() ;
    listing       = g ;
    return true;
      }
  }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

         int status,
         String title,
         String msg)
    {
  Reply error = request.makeReply(status);
  HtmlGenerator g = CvsFrame.getHtmlGenerator(title);
  g.append("<span class=\"title\">",title,"</span>\n");
  g.append("<p>",msg);
  error.setStream(g);
  return error;
    }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

  }
  return null;
    }

    protected HtmlGenerator getHtmlGenerator(String title) {
  HtmlGenerator g = new HtmlGenerator(title);
  g.addStyle("BODY {color: black; background: white; "+
       "font-family: serif; margin-top: 35px }\n");
  return g;
    }
View Full Code Here

Examples of org.w3c.jigsaw.html.HtmlGenerator

      case PutListResource.FILE_PB:
      case PutListResource.FILE_DEL:
    return null;
      case PutListResource.FILE_MG:
    Reply   msg = request.makeReply(HTTP.CONFLICT);
    HtmlGenerator g = getHtmlGenerator("Warning");
    g.append ("<H1>Warning</H1> The file on publish space has "+
        "been modified directly but attempting to merge "+
        "has succeed.<p>"+
        "You should update the file before editing "+
        "it again.");
    msg.setStream(g);
    return msg;
      case PutListResource.FILE_CF:
    Reply error = request.makeReply(HTTP.CONFLICT);
    HtmlGenerator gerr = getHtmlGenerator("Warning");
    gerr.append ("<H1>Warning</H1> The file on publish space has "+
           "been modified directly and attempting to merge"+
           " has failed.<p>"+
           "Ask your system administrator.");
    error.setStream(gerr);
    return error;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.