Hotová jednoduchá JSP vrstva
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed Feb 11 20:08:00 2009 +0100 (2009-02-11)
changeset 562bddd9b51fb
parent 4 e3e2a3a4c36a
child 6 38625daa449b
Hotová jednoduchá JSP vrstva
java/HrisniciSpameri/nbproject/private/private.xml
java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java
java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/SitovaAdresa.java
java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Souhrn.java
java/HrisniciSpameri/web/souhrn.jspx
java/HrisniciSpameri/web/styl.css
sql/schéma.sql
     1.1 --- a/java/HrisniciSpameri/nbproject/private/private.xml	Wed Feb 11 19:36:28 2009 +0100
     1.2 +++ b/java/HrisniciSpameri/nbproject/private/private.xml	Wed Feb 11 20:08:00 2009 +0100
     1.3 @@ -1,2 +1,12 @@
     1.4  <?xml version="1.0" encoding="UTF-8"?>
     1.5 -<project-private xmlns="http://www.netbeans.org/ns/project-private/1"/>
     1.6 +<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
     1.7 +    <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
     1.8 +    <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/1">
     1.9 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java</file>
    1.10 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Cil.java</file>
    1.11 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Souhrn.java</file>
    1.12 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/index.jsp</file>
    1.13 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/souhrn.jspx</file>
    1.14 +        <file>file:/home/fiki/src/HrisniciSpameri/java/HrisniciSpameri/web/styl.css</file>
    1.15 +    </open-files>
    1.16 +</project-private>
     2.1 --- a/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java	Wed Feb 11 19:36:28 2009 +0100
     2.2 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/DenniSouhrn.java	Wed Feb 11 20:08:00 2009 +0100
     2.3 @@ -1,6 +1,7 @@
     2.4  package cz.frantovo.hrisniciSpameri;
     2.5  
     2.6  import cz.frantovo.hrisniciSpameri.dto.Cil;
     2.7 +import cz.frantovo.hrisniciSpameri.dto.SitovaAdresa;
     2.8  import cz.frantovo.hrisniciSpameri.dto.Souhrn;
     2.9  import java.io.Serializable;
    2.10  import java.net.InetAddress;
    2.11 @@ -72,12 +73,8 @@
    2.12          Cil cil = new Cil(1, "Frantovo.cz", "http://frantovo.cz/blog/", null, null);
    2.13  
    2.14          for (int i = 1; i < 11; i++) {
    2.15 -            try {
    2.16 -                Souhrn s = new Souhrn(getVychoziDen(), InetAddress.getByName("127.0.0.1"), 100 + i, cil);
    2.17 -                souhrn.add(s);
    2.18 -            } catch (UnknownHostException e) {
    2.19 -                log.log(Level.SEVERE, null, e);
    2.20 -            }
    2.21 +            Souhrn s = new Souhrn(getVychoziDen(), new SitovaAdresa("10.0.0.8", i + ".frantovo.cz"), 100 + i, cil);
    2.22 +            souhrn.add(s);
    2.23          }
    2.24  
    2.25          return souhrn;
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/SitovaAdresa.java	Wed Feb 11 20:08:00 2009 +0100
     3.3 @@ -0,0 +1,33 @@
     3.4 +package cz.frantovo.hrisniciSpameri.dto;
     3.5 +
     3.6 +/**
     3.7 + * <em>Hloupá</em> přepravka na dvojici IP adresa – doména.
     3.8 + * Neklade si za cíl DNS překlady, jen přenáší tyto dvě hodnoty.
     3.9 + * @author fiki
    3.10 + */
    3.11 +public class SitovaAdresa {
    3.12 +
    3.13 +    private String ip;
    3.14 +    private String domena;
    3.15 +
    3.16 +    public String getIp() {
    3.17 +        return ip;
    3.18 +    }
    3.19 +
    3.20 +    public void setIp(String ip) {
    3.21 +        this.ip = ip;
    3.22 +    }
    3.23 +
    3.24 +    public String getDomena() {
    3.25 +        return domena;
    3.26 +    }
    3.27 +
    3.28 +    public void setDomena(String domena) {
    3.29 +        this.domena = domena;
    3.30 +    }
    3.31 +
    3.32 +    public SitovaAdresa(String ip, String domena) {
    3.33 +        this.ip = ip;
    3.34 +        this.domena = domena;
    3.35 +    }
    3.36 +}
     4.1 --- a/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Souhrn.java	Wed Feb 11 19:36:28 2009 +0100
     4.2 +++ b/java/HrisniciSpameri/src/java/cz/frantovo/hrisniciSpameri/dto/Souhrn.java	Wed Feb 11 20:08:00 2009 +0100
     4.3 @@ -12,7 +12,7 @@
     4.4  
     4.5      private static final long serialVersionUID = 6502435361626487366L;
     4.6      private Date den;
     4.7 -    private InetAddress adresa;
     4.8 +    private SitovaAdresa adresa;
     4.9      private int pocet;
    4.10      private Cil cil;
    4.11  
    4.12 @@ -40,15 +40,15 @@
    4.13          this.cil = cil;
    4.14      }
    4.15  
    4.16 -    public InetAddress getAdresa() {
    4.17 +    public SitovaAdresa getAdresa() {
    4.18          return adresa;
    4.19      }
    4.20  
    4.21 -    public void setAdresa(InetAddress adresa) {
    4.22 +    public void setAdresa(SitovaAdresa adresa) {
    4.23          this.adresa = adresa;
    4.24      }
    4.25  
    4.26 -    public Souhrn(Date den, InetAddress adresa, int pocet, Cil cil) {
    4.27 +    public Souhrn(Date den, SitovaAdresa adresa, int pocet, Cil cil) {
    4.28          this.den = den;
    4.29          this.adresa = adresa;
    4.30          this.pocet = pocet;
     5.1 --- a/java/HrisniciSpameri/web/souhrn.jspx	Wed Feb 11 19:36:28 2009 +0100
     5.2 +++ b/java/HrisniciSpameri/web/souhrn.jspx	Wed Feb 11 20:08:00 2009 +0100
     5.3 @@ -6,6 +6,7 @@
     5.4  -->
     5.5  <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
     5.6            xmlns:c="http://java.sun.com/jsp/jstl/core"
     5.7 +          xmlns:f="http://java.sun.com/jsp/jstl/functions"
     5.8            version="2.0">
     5.9  
    5.10      <jsp:useBean id="denniSouhrn" class="cz.frantovo.hrisniciSpameri.DenniSouhrn" scope="page"/>
    5.11 @@ -25,10 +26,18 @@
    5.12          <tbody>
    5.13              <c:forEach var="s" items="${denniSouhrn.souhrn}">
    5.14                  <tr>
    5.15 -                    <td><c:out value="${s.adresa}"/></td>
    5.16 -                    <td><c:out value="${s.adresa}"/></td>
    5.17 +                    <td><c:out value="${s.adresa.ip}"/></td>
    5.18 +                    <td><c:out value="${s.adresa.domena}"/></td>
    5.19                      <td><c:out value="${s.pocet}"/></td>
    5.20 -                    <td><c:out value="${s.cil.nazev}"/></td>
    5.21 +                    <td><c:choose>
    5.22 +                            <c:when test="${s.cil.url == null}">
    5.23 +                                <c:out value="${s.cil.nazev}"/>
    5.24 +                            </c:when>
    5.25 +                            <c:otherwise>
    5.26 +                                <a href="${f:escapeXml(s.cil.url)}"><c:out value="${s.cil.nazev}"/></a>
    5.27 +                            </c:otherwise>
    5.28 +                        </c:choose>
    5.29 +                    </td>
    5.30                  </tr>
    5.31              </c:forEach>
    5.32          </tbody>
     6.1 --- a/java/HrisniciSpameri/web/styl.css	Wed Feb 11 19:36:28 2009 +0100
     6.2 +++ b/java/HrisniciSpameri/web/styl.css	Wed Feb 11 20:08:00 2009 +0100
     6.3 @@ -1,3 +1,7 @@
     6.4 +body {
     6.5 +    font-family: sans-serif;
     6.6 +}
     6.7 +
     6.8  table {
     6.9      border: 1px solid black;
    6.10      border-collapse:collapse;
    6.11 @@ -5,6 +9,8 @@
    6.12  td {
    6.13      border: 1px solid black;
    6.14      padding: 3px;
    6.15 +    padding-left: 5px;
    6.16 +    padding-right: 5px;
    6.17  }
    6.18  thead {
    6.19      background: silver;
     7.1 --- a/sql/schéma.sql	Wed Feb 11 19:36:28 2009 +0100
     7.2 +++ b/sql/schéma.sql	Wed Feb 11 20:08:00 2009 +0100
     7.3 @@ -26,7 +26,7 @@
     7.4  CREATE TABLE souhrn
     7.5  (
     7.6    den date NOT NULL,
     7.7 -  ip inet NOT NULL, -- IP adresa hříšníka
     7.8 +  ip character varying NOT NULL, -- IP adresa hříšníka
     7.9    domena character varying, -- Doménové jméno hříšníka (překlad IP adresy)
    7.10    pocet bigint NOT NULL, -- Počet pokusů o spamování v daném dni
    7.11    cil bigint, -- Cíl útoku - spamování