Question

Je génère actuellement des vtt utilisant JSP.J'ai découvert que certaines plates-formes ne reconnaissent pas ces vcards générés à moins que leurs lignes ne soient séparées par des retours de chariot ( Cr ), et JSP semble utiliser juste une alimentation en ligne ( LF ) parpar défaut pour séparer les lignes.

Connaissez-vous un moyen de dire à la JSP d'inclure un CR entre chaque ligne?

J'espère que quelqu'un a un indice, car je n'ai pas beaucoup trouvé là-bas ...

Merci d'avance!

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top