Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

forwadring to Servlet from Remote object fails

hi guys
I am generating Pdf from flex. From my flex client i call 'RemoteCustomer'  a java remote object and call generatePdf()method. In this method i am trying to forward to a java Servlet called PDFServlet which is in the same package as RemoteCustomer but i get error shown below


public class RemoteCustomer{

public void generatePdf(Workflow workflow){
boolean pdfStatus = true;
try{
String sessionKeyName = "PDF_BYTESTREAM";
ByteArrayOutputStream pdfByteStream = null;
HttpServletRequest request = flex.messaging.FlexContext.getHttpRequest();
HttpServletResponse response = flex.messaging.FlexContext.getHttpResponse();
pdfByteStream = PdfMaker.makePdf(workflow); -- this contains the byte stream which needs to be passed to servlet
request.getSession().setAttribute(sessionKeyName,p dfByteStream);
request.getRequestDispatcher("PDFServlet").forward(request, response); //PDFServlet exist in same package as this class
}
}

PDFServlet is my servlet class but unfortunately its not forwarding to the servlet.

It says

org.springframework.flex.servlet.MessageBrokerHand lerAdapter handle Received invalid request for endpoint path '/messagebroker/PDFServlet'.[4/26/11 12:58:10:850 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse addHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:865 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setDateHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:865 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:928 EDT] 00000029 srt W com.ibm.ws.webcontainer.srt.SRTServletResponse setIntHeader WARNING: Cannot set header. Response already committed.
[4/26/11 12:58:10:944 EDT] 00000029 SystemOut O [BlazeDS]SRVE0209E: Writer already obtained
java.lang.IllegalStateException: SRVE0209E: Writer already obtained
at com.ibm.ws.webcontainer.srt.SRTServletResponse.get Outpu

Any help will be greatly appreciated
thanks
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

Well I guess you are recieving this error because you are using the http-request and response objects to output your data. Unfortunately blazeds uses these objects to output an AMF serialized form of the data returned by a method call. So you are bypassing the AMF serialization and this is what BlazeDS and Flex are complaining about. In BlazeDS ByteArrays are extremely imperformant (byte[] would be great, but Byte[] really sucks (takes about 10 times the memory).

I would suggest to call your Servlet directly from the Flex client using an UrlRequest or something like that.
Avatar of Jay Roy

ASKER

yeah, makes sense

when you said
>>>byte[] would be great, but Byte[] really sucks

whats the difference between byte[] and Byte[]

thx
ASKER CERTIFIED SOLUTION
Avatar of ChristoferDutz
ChristoferDutz
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial