Código PHP:
%>
<%
//fprqN:Specifies the pitch of a font in the font table.
//String strDir = "usr/local/tomcat/webapps/ROOT/";
//String defDir = "/home/cepagi/Documents/";
out.println(defDir+"<P>");
File file2 = new File(defDir+"GeneratedRTF2.RTF");
FileWriter fWriter;
BufferedWriter bWriter;
try {
fWriter = new FileWriter(file2);
bWriter = new BufferedWriter(fWriter);
bWriter.write(sNewBrackets+sRTFHeader+sRTFCharSet+sRTFDeff+MyFontTable+MyColorTable);
bWriter.write("\\cf0\\cb1"+sFontN0+sFontS24+ "Las Palabras\\par \n");
bWriter.write("\\cf1\\cb0"+sFontN0+"\\i\\fs20"+ "Primera Palabra, italica con \\\\i\\par \n");
bWriter.write("\\cf1\\cb0"+sFontN0+"\\ul\\fs16"+ "Segunda Palabra, subrayada con \\\\ul\\par \n");
bWriter.write("\\cf1\\cb0"+sFontN0+"\\b\\fs48"+ "Tercera Palabra, Negrita con \\\\b \n");
//bWriter.write("\\cf0\\cb1"+sFontN1+sFontS24+ "Otra Hoja con \\\\page\\par \n");
bWriter.write("\\cf3\\cb0"+sFontN1+"\\i0\\fs20"+ "Quitar, Italica con \\\\i0\\par \n");
bWriter.write("\\cf4\\cb0"+sFontN1+"\\ul0\\fs16"+ "Quitar Subrayada con \\\\ul0\\par \n");
bWriter.write("\\cf5\\cb0"+sFontN1+"\\b0\\fs48"+ "Quitar, Negrita con \\\\b0 \n");
bWriter.write("\\par \n");
bWriter.write("\\cf3\\cb0"+sFontN1+"\\qc\\fs12"+ "Centrada con \\\\qc \\par\n");
bWriter.write("\\cf4\\cb0"+sFontN1+"\\qd\\fs12"+ "Distribuida con \\\\qd \\par\n");
bWriter.write("\\cf5\\cb0"+sFontN1+"\\fs12");
bWriter.write("\\ql Izquierda con \\\\ql\\par \n");
bWriter.write("\\qr Derecha con \\\\qr\\par \n");
bWriter.write("\\par \n");
bWriter.write(sNPage);
bWriter.write("\n");
//Se hará una tabla de 3x3,Mezclando (1,3) con (2,3) y (3,1) con (3,2)
//Fila 1
//\InicioDeTabla[\EspacioTabla][\PosicionTabla]\JustificacionTabla[\FilaCabecera]
bWriter.write("\\trowd\\trgaph100\\trleft1000\\trqc\\trhdr \n");
//\BordedeFila\TipoDeBorde\AnchoDeBorde\ColorDeBorde
bWriter.write("\\trbrdrt\\brdrdb\\brdrw15\\brdrcf3 \\trbrdrl\\brdrdb\\brdrw15\\brdrcf4 ");
bWriter.write("\\trbrdrb\\brdrdb\\brdrw15\\brdrcf5 \\trbrdrr\\brdrdb\\brdrw15\\brdrcf3 ");
bWriter.write("\\trbrdrh\\brdrdb\\brdrw15\\brdrcf4 \\trbrdrv\\brdrdb\\brdrw15\\brdrcf5 ");
bWriter.write("\n");
//\BordeDeCelda\TipoDeBorde\AnchoDeBorde\ColorDeBorde\[AlineacionVertical]);
//Celda(1,1)
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx3000 \n");
//Celda(1,2)
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx6000 \n");
//Celda(1,3)
bWriter.write("\\clvmgf \n");
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx9000 \n");
//Fin de Definición de Tabla (Fila));
bWriter.write("\\pard\\intbl\\pard\\plain \n");
//Inicio de Llenado de Celda (1,1)
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\ql ");
//Formato de Celda
//\ColorFrente\ColorFondo\TipoFuente\Tamaño
bWriter.write("\\cf3\\cb2"+"\\f1"+"\\fs24");
//Contenido
bWriter.write("CELDA (1,1)");
//Fin de Llenado de Celda (1,1)
bWriter.write("\\cell \n");
//Inicio de Llenado de Celda (1,2)
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\ql ");
bWriter.write("\\cf4\\cb2"+"\\f1"+"\\fs24");
bWriter.write("CELDA (1,2)");
bWriter.write("\\cell \n");
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\qd ");
bWriter.write("\\cf5\\cb2"+"\\f1"+"\\fs24");
bWriter.write("CELDA (1,3)");
bWriter.write("\\cell \n");
//Fin de llenado de Tabla (o Fila 1)
bWriter.write("\\row\\pard \n");
bWriter.write("\n");
//Fila 2
bWriter.write("\\trowd\\trgaph100\\trleft1000\\trqc \n");
//Celda(2,1)
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx3000 \n");
//Celda(2,2)
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx6000 \n");
//Celda(2,3)
bWriter.write("\\clvmgr \n");
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx9000 \n");
bWriter.write("\\pard\\intbl\\pard\\plain \n");
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\qr ");
bWriter.write("\\cf1\\cb2"+"\\f2"+"\\fs20");
bWriter.write("CELDA (2,1)");
bWriter.write("\\cell \n");
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\qr ");
bWriter.write("\\cf1\\cb2"+"\\f2"+"\\fs24");
bWriter.write("CELDA (2,2)");
bWriter.write("\\cell \n");
//Para (2,3 )No se define formato ni inicio de llenado, solo el cierre
bWriter.write("\\cell \n");
bWriter.write("\\row\\pard \n");
bWriter.write("\n");
//Fila 3
bWriter.write("\\trowd\\trgaph100\\trleft1000\\trqc \n");
//Celda(2,1)
//La combinación horizontal se hace definiendo solo una celda
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx6000 \n");
//Celda(2,3)
bWriter.write("\\clbrdrt\\brdrs\\brdrw1\\brdrcf1 \\clbrdrl\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\clbrdrb\\brdrs\\brdrw1\\brdrcf1 \\clbrdrr\\brdrs\\brdrw1\\brdrcf1 ");
bWriter.write("\\cellx9000 \n");
bWriter.write("\\pard\\intbl\\pard\\plain \n");
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\qc ");
bWriter.write("\\cf1\\cb2"+"\\f2"+"\\fs20");
bWriter.write("CELDA (2,1)");
bWriter.write("\\cell \n");
bWriter.write("\\pard\\plain\\intbl\\ltrpar\\qc ");
bWriter.write("\\cf1\\cb2"+"\\f2"+"\\fs24");
bWriter.write("CELDA (3,3)");
bWriter.write("\\cell \n");
bWriter.write("\\row\\pard \n");
bWriter.write(sNPage);
bWriter.write("\\cf1\\cb2"+sFontN1+sFontS24+"Hoja 3 con \\\\page, Colores de Palabras y Parrafos\\par");
bWriter.write("\\cbpat2\\cfpat3"+sFontN1+sNPar+"\\fs18\\\\cbpat2 \\\\cfpat3 \n");
bWriter.write("\\cbpat2\\cfpat4"+sFontN1+sNPar+"\\fs18\\\\cbpat2 \\\\cfpat4 \n");
bWriter.write("\\cbpat2\\cfpat5"+sFontN1+sNPar+"\\fs18\\\\cbpat2 \\\\cfpat5 \n");
bWriter.write("\\cbpat3\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\cbpat3 \\\\cfpat2 \n");
bWriter.write("\\cbpat4\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\cbpat4 \\\\cfpat2 \n");
bWriter.write("\\cbpat5\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\cbpat5 \\\\cfpat2 \n");
bWriter.write("\\chcbpat3\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\chcbpat3 \\\\cfpat2 \n");
bWriter.write("\\chcbpat4\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\chcbpat4 \\\\cfpat2 \n");
bWriter.write("\\chcbpat5\\cfpat2"+sFontN1+sNPar+"\\fs18\\\\chcbpat5 \\\\cfpat2 \n");
bWriter.write("\\chcbpat2\\cfpat3"+sFontN1+sNPar+"\\fs18\\\\chcbpat2 \\\\cfpat3 \n");
bWriter.write("\\chcbpat2\\cfpat4"+sFontN1+sNPar+"\\fs18\\\\chcbpat2 \\\\cfpat4 \n");
bWriter.write("\\chcbpat2\\cfpat5"+sFontN1+sNPar+"\\fs18\\\\chcbpat2 \\\\cfpat5 \n");
bWriter.write("\\chcfpat2\\cbpat3"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\cbpat3 \n");
bWriter.write("\\chcfpat2\\cbpat4"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\cbpat4 \n");
bWriter.write("\\chcfpat2\\cbpat5"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\cbpat5 \n");
bWriter.write("\\chcfpat3\\cbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat3 \\\\cbpat2 \n");
bWriter.write("\\chcfpat4\\cbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat4 \\\\cbpat2 \n");
bWriter.write("\\chcfpat5\\cbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat5 \\\\cbpat2 \n");
bWriter.write("\\chcfpat3\\chcbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat3 \\\\chcbpat2 \n");
bWriter.write("\\chcfpat4\\chcbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat4 \\\\chcbpat2 \n");
bWriter.write("\\chcfpat5\\chcbpat2"+sFontN1+sNPar+"\\fs18\\\\chcfpat5 \\\\chcbpat2 \n");
bWriter.write("\\chcfpat1\\chcbpat3"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\chcbpat3 \n");
bWriter.write("\\chcfpat1\\chcbpat4"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\chcbpat4 \n");
bWriter.write("\\chcfpat1\\chcbpat5"+sFontN1+sNPar+"\\fs18\\\\chcfpat2 \\\\chcbpat5 \n");
bWriter.write(sEndBrackets);
bWriter.close();
fWriter.close();
out.println("<a href=\"http://192.168.0.1:8080/GeneratedRTF2.RTF\"><CODE>GeneratedRTF2.RTF</CODE></a><P>");
out.println("<a href=\"GeneratedRTF2.RTF\"><CODE>Relativo GeneratedRTF2.RTF</CODE></a><P>");
out.println("<a href=\"GeneratedRTF2.RTF\" TYPE=\"application/java\"> TIPO Aplicación GeneratedRTF2.RTF</CODE></a><P>");
//out.println("<OBJECT file=\"GeneratedRTF2.RTF\" TYPE=\"href\"> TIPO OBJECT GeneratedRTF2.RTF</OBJECT><P>");
out.println("<FORM ACTION=WriteReadFile.jsp ENCTYPE=\"MULTIPART/FORM-DATA\" METHOD=POST>");
out.println("<BR>Select file to upload <INPUT TYPE=FILE Name=Filename>");
out.println("<INPUT TYPE=SUBMIT VALUE=\"Upload\">");
out.println("</FORM>");
} catch (IOException e) {
e.printStackTrace();
}
%>
</TABLE>
</CENTER>
</BODY>
</HTML>