tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Power-Netz \(Schwarz\)" <schw...@power-netz.de>
Subject AW: image responses via JSP : jasper produces empty lines in sourcecode!!!
Date Thu, 08 Aug 2002 12:33:48 GMT

> To do that, you have to use something like that:
>
> java.io.OutputStream o = response.getOutputStream();
> o.write(...);


yeap. it works now.

For everyone who is interested:

<%@ page import="java.io.*"
%><%@ page import="Base64.*"
%><%@ page session="true"
%><jsp:setProperty name="filter" property="action" param="Action"
/><%
    response.setHeader("Cache-Control","no-cache");
    response.setHeader("Expires","0");
    if (filter.getAction().compareTo("detail")==0) {
		String base64 = "";
		int i=0;
		try {
// DECODE of an EMAIL with attachment ( Image/tiff ) in an StringArray (
line by line )
			while (!a[i].startsWith("Content-Transfer-Encoding: base64")) i++;
//				System.out.println("Base64 Encoding gefunden!");
			while (a[i].trim().length()!=0) i++;
//				System.out.println("Leerzeile 1 gefunden!");
//			System.out.println("xxxx:"+a[i]);
			i++;
//			System.out.println("xxxx:"+a[i]);
			while (a[i].trim().length()!=0) {
				base64 += a[i];
				i++;
			}
			byte[] bytes = Base64.decode(base64);

			response.setContentType("image/tiff");
			response.setHeader("Content-length",String.valueOf(bytes.length));

			if (bytes!=null) {
				response.getOutputStream().write(bytes);
			} else out.write("<HTML><HEAD></HEAD><BODY>NOT PROCESSED</BODY></HTML>");
		} catch (Exception e) {
			out.write("<HTML><HEAD></HEAD><BODY>NOT PROCESSED</BODY></HTML>");
		}
	} else {
	....


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message