|
|
|
|
|
|
Re: How to get the Output Stream of the Servlet? [message #71520 is a reply to message #71501] |
Thu, 24 January 2008 10:01   |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
Lars Martin wrote:
> Ben W. wrote:
>> hmm, when i put this line the Activator constructor or anywhere else in
>> Activator.java the app won't start anymore (entrypoint does not exist). i
>> put it in preWindoOpen(), this works for now. thank you very much lars!
> I can't believe this. We've successfully implemented custom service
> handlers several times before. The registerServiceHandler() method simply
> put the given handler into a map. That's all. Can you run your application
> in debug mode. I'm sure there is some other exception catched and wrapped
> with this "entry point does not exist" execption.
yes indeed, there was something in MyServiceHandler() that threw an
exceptions. sry, my mistake, didn't think that far...
>> but are all these "Discouraged access" warnings are annoying somehow...
> Yes.
as long as they don't interfere with the execution of the programm...
>> now only the problem with the resources remains :).
> You don't need to register a resource when using your own service handler.
> You can implement whatever your want to write into the request
> outputstream.
> public void service() throws IOException, ServletException {
> HttpServletResponse response = ContextProvider.getResponse();
> response.setContentType( "..." );
> response.setHeader( "Content-Disposition", "attachment;
> filename="..."" );
> response.getOutputStream().write( ... );
> }
thats what i did, but with a file i copied into the folder in eclipse.
when i dynamically generate a pdf file i have to store it in order to do
the
?custom_service_handler=myServiceHandler&file=pdftest.pd f trick. i can
read the resource and put it as bytearray into the response content with
the proper mime type. but the pdf is created in another point in the
application... so i need to do a data exchange, and i don't know how to do
it except register the created pdf as a resource and read it in the
service() method...
|
|
|
|
Re: How to get the Output Stream of the Servlet? [message #71557 is a reply to message #71538] |
Thu, 24 January 2008 10:35  |
Eclipse User |
|
|
|
Originally posted by: benjamin.wolff.web.de
Lars Martin wrote:
> Ben W. wrote:
>> thats what i did, but with a file i copied into the folder in eclipse.
>> when i dynamically generate a pdf file i have to store it in order to do
>> the
>> ?custom_service_handler=myServiceHandler&file=pdftest.pd f trick. i can
>> read the resource and put it as bytearray into the response content with
>> the proper mime type. but the pdf is created in another point in the
>> application... so i need to do a data exchange, and i don't know how to do
>> it except register the created pdf as a resource and read it in the
>> service() method...
> Then register your resource via
> RWT.getResourceManger().register( "itext.pdf", ... InputStream );
> and serve the requested file in your custom service handler via
> RWT.getResourceAsStream( "itext.pdf" );
this is what i tried:
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
RWT.getResourceManager().setContextLoader(getClass().getClas sLoader());
RWT.getResourceManager().register("/reports/test2.pdf", bais);
System.out.println(RWT.getResourceManager().getResource("/reports/test2.pdf "));
the sysout returns "null", so i assume that the register failed...
|
|
|
Powered by
FUDForum. Page generated in 0.03293 seconds