[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jetspeed-user
Subject:    Re: non-text in JSP(mixed content type in portlet)
From:       Raphaël_Luta <raphael () apache ! org>
Date:       2004-05-29 7:43:14
Message-ID: D7705A3A-B143-11D8-98B1-003065A2559C () apache ! org
[Download RAW message or body]


Le 21 mai 04, à 19:10, Sihong Fan a écrit :

> I want hide(security reason) a group of static PDF in
> jetspeed. So I read and write the PDF in jsp. This jsp
> page can read and write jsp out side jetspeed. But
> after I put it into jetspeed. It give me 'getWriter()
> has already been called for this response ' error.
>
> Does any one know how to solve the problem?
>
> Here is my jsp
>
> <%@ page import="java.io.*" %>
> <%@ page import="java.net.*" %>
> <%
> OutputStream o = response.getOutputStream();
> response.setContentType("application/pdf");
> File f = new File("pdf/test2.pdf");
> InputStream is = f.toURL().openStream();
> byte[] buf = new byte[32 * 1024];
> int nRead = 0;
> while( (nRead=is.read(buf)) != -1 ) {
>      o.write(buf, 0, nRead);
> }
> %>

You can't mix 2 content-types in a single HTTP response. Your portlet  
needs to output
a valid HTML markup that the browser will then execute to to request the
PDF.

portlet sends:
document.location.href="http://myportal/jetspeed/portal/layout/raw.jsp/ 
template/sendPDF.jsp"

and put your sendPDF.jsp in webapp/WEB-INF/templates/jsp/screens/

you'll also need a webapp/WEB-INF/templates/jsp/layouts/raw.jsp:
<%
String screenJsp = (String)request.getAttribute("screenJsp");
%><jsp:include page="<%= screenJsp %>" flush="true" />


--
Raphaël Luta - raphael@apache.org
Apache Jetspeed - Enterprise Portal in Java
http://portals.apache.org/


---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-user-help@jakarta.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic