C'è un modo per creare un rendimento del carrello di stampa JSP (CR)?
Domanda
Attualmente sto generando alcune vCARD usando JSP.Ho scoperto che alcune piattaforme non riconoscono queste vCard generate a meno che le loro linee non siano separate dai ritorni del carrello ( CR ) e JSP sembra utilizzare solo feed Line ( LF ) daimpostazione predefinita per separare le linee.
Ragazzi che conosce un modo per raccontare il JSP di includere un CR tra ogni linea?
Spero che qualcuno abbia un indizio, perché non ho trovato molto là fuori ...
Grazie in anticipo!
Soluzione
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.