ok, posto il flusso logico e il codice della classe
dunque:

1. ricavo i 2 testi da db e li passo ad un'istanza di AnalisiDiff con il metodo findDiff


public class AnalisiDiff{

FileOutputStream fileoutstream = null;
Writer printer=null;
String testoV1="";
String testoV2="";
Hashtable testiCorretti=new Hashtable();



public Hashtable findDiff(String testo1, String testo2, ServletContext sc){

testoV1=new String(testo1);
testoV2=new String(testo2);

try {


if(testoV1.equals(testoV2)){
testoV2="Nessun cambiamento dalla prima versione";
}else{

String mostraDiff="";
String firFileName=sc.getRealPath("/")+"/diffutil/1.htm";
String secFileName=sc.getRealPath("/")+"/diffutil/2.htm";

testo1=testoV1.replace(">",">\r");
testo1=testoV1.replace(".",".\n");

testo2=testoV2.replace(">",">\r");
testo2=testoV2.replace(".",".\n");

fileoutstream = new FileOutputStream(firFileName);
printer = new OutputStreamWriter(fileoutstream, "utf8");
printer.write("<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n<title>Diff</title>\n</head>\n<body>\n");
printer.write(testo1);
this.closeWriter();

fileoutstream = new FileOutputStream(secFileName);
printer = new OutputStreamWriter(fileoutstream, "utf8");
printer.write("<html>\n<head>\n<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>\n<title>Diff</title>\n</head>\n<body>\n");
printer.write(testo2);
this.closeWriter();

DiffUTF8 d = new DiffUTF8();
d.doDiff(firFileName, secFileName);

mostraDiff=DiffUTF8.differenze;

StringTokenizer stk = new StringTokenizer(mostraDiff,"*");

String token="";
String tokenFocus="";

while(stk.hasMoreTokens()){

token=stk.nextToken();
if(token.equals("changed from")){
tokenFocus=stk.nextToken();
testoV1=testoV1.replace(tokenFocus,"<span class='cambiato'>"+tokenFocus+"</span>");
}
if(token.equals("changed to")){
tokenFocus=stk.nextToken();
testoV2=testoV2.replace(tokenFocus,"<span class='cambiato'>"+tokenFocus+"</span>");
}
if(token.equals("delete")){
tokenFocus=stk.nextToken();
testoV1=testoV1.replace(tokenFocus,"<span class='cancellato'>"+tokenFocus+"</span>");
}
if(token.equals("before")){
tokenFocus=stk.nextToken();
testoV2=testoV2.replace(tokenFocus,"<span class='aggiunto'>"+tokenFocus+"</span>");
}
if(token.equals("moved")){
tokenFocus=stk.nextToken();
testoV1=testoV1.replace(tokenFocus,"<span class='spostato'>"+tokenFocus+"</span>");
testoV2=testoV2.replace(tokenFocus,"<span class='spostato'>"+tokenFocus+"</span>");
}


if(!tokenFocus.equals("")){

System.out.println (tokenFocus);

}

}

}


testiCorretti.put("testo1",testoV1);
testiCorretti.put("testo2",testoV2);


}
catch (Exception ex) {System.out.println (ex);}


return testiCorretti;

}

public void closeWriter(){
try { printer.write("</body></html>");printer.flush(); printer.close();}
catch (Exception ex) {ex.printStackTrace();}
}



}


DiffUTF8 si occupa di fare il merge dei file e mi torna una stringa (mostraDiff) che contiene solo le parti modificate precedute dal tipo di modifica. per es

*change from*abra cadabra ula uba*change to*abra cadabra uba*

io analizzo questa stringa con un tokenizer e a seconda del tipo di modifica applico una diversa formattazione al testo

il problema visto più da vicino è che una volta modificati i testi e ricaricata la pagina, il primo testo viene mostrato correttamente, mentre il secondo mantiene le vecchie formattazioni + le nuove