¿Hay alguna forma de hacer que un carruaje de impresión JSP vuelva (CR)?
Pregunta
Actualmente estoy generando algunas vCards usando JSP.Descubrí algunas plataformas, no reconocí estas vCards generadas a menos que sus líneas estén separadas por los retornos de carro ( cr ), y JSP parece usar la alimentación de la línea ( lf ) porPredeterminado para separar las líneas.
¿Conocen todas las formas de decirle a la JSP que incluya una CR entre cada línea?
Espero que alguien tenga una pista, porque no he encontrado mucho por ahí ...
¡Gracias de antemano!
Solución
If you need to emit non-HTML format, then you should be using a servlet instead of a JSP. This way you're not dependent on the JspServlet and/or appserver specifics how the output is been generated. More than often you simply cannot control this.
Using a servlet is relatively simple. Create a class which extends HttpServlet
and implement the doGet()
method like follows:
response.setContentType("text/x-vcard");
response.setCharacterEncoding("UTF-8");
PrintWriter writer = response.getWriter();
writer.write("BEGIN:VCARD" + (char) 10);
// ...
Map this in web.xml
on an url-pattern
of /vcard/*
or *.vcf
or whatever and use the request servletpath/pathinfo/params to generate output dynamically based on the URL.