That's our experience. The default target valve works as follows:
1.Set Content Type 2.Render module/content 3.Print to the output stream This happens after the action (The DefaultActionValve) in the default pipeline. So if you call setContentType(...) and then write to the output stream in your action, calling setContentType again in the target valve throws an exception because you cant reset the content type after the output writer has already been opened. We need to come up with a workaround for this. > -----Original Message----- > From: Aravinda Addala [mailto:[EMAIL PROTECTED]] > Sent: 31 January 2002 17:45 > To: Turbine Users List > Subject: RE: Please help. Content type: Sending pdf content to the > browser > > > Yes. It is data.setContentType that causes this to happen. > I tried this code: > public void doProcess( RunData data, TemplateContext context ) throws > Exception > { > > String _contentType = "text/html"; > data.setContentType(_contentType); > data.getOut().print("Test"); > } > > This results in an exception displayed in the browser. Does this > mean that I > can not set the content type in my actions at the moment? > > Aravinda. > > -----Original Message----- > From: Gareth Coltman [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 31, 2002 5:37 PM > To: Turbine Users List > Subject: RE: Please help. Content type: Sending pdf content to the > browser > > > Yes, this is the reason why it didn't load acrobat. But it wouldn't have > worked even with a PDF, because Turbine will append an exception trace to > the output stream, when it tries to set the content type in the > DefaultTargetValve. > > Gareth > > > -----Original Message----- > > From: Aaron Smuts [mailto:[EMAIL PROTECTED]] > > Sent: 31 January 2002 17:26 > > To: Turbine Users List > > Subject: RE: Please help. Content type: Sending pdf content to the > > browser > > > > > > The url must end in .pdf for the unknow to work. If you can define the > > class to handle the request in a parameter then you can append > .pdf or if > > the configuration uses a * for the url > > > > > -----Original Message----- > > > From: Aravinda Addala [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, January 31, 2002 11:43 AM > > > To: Turbine Users List > > > Subject: RE: Please help. Content type: Sending pdf content to > > the browser > > > > > > I have tried using data.setContentType("unknown"). When I run > > this action, > > > browser asks me to open an application associated with this type of > > > content. > > > I opened it in WordPad. Turbine seems is appending the > > following error to > > > the output stream. > > > > > > The first part of the output (from %FDF-1.2 to %%EOF) is a valid fdf > > > document and works if I copy and paste in a blank file. > > > But Turbine seems to append everything after %%EOF. > > > > > > May be somebody could be able to help. > > > > > > Thank you, > > > Aravind. > > > > > > OUTPUT IS: > > > > > > %FDF-1.2 > > > %���� > > > 1 0 obj > > > << > > > /FDF << /Fields 2 0 R /F (http://localhost:7001/parioapp/ToPDF.pdf)>> > > > >> > > > endobj > > > 2 0 obj > > > [ > > > << /T (test)/V [ (test1)(test2)] >> > > > ] > > > endobj > > > trailer > > > << > > > /Root 1 0 R > > > > > > >> > > > %%EOF > > > <pre> > > > java.lang.IllegalStateException: Attempt to change ContentType after > > > calling > > > getWriter() (cannot change charset from 'null' to 'ISO-8859-1') > > > at > > > > > > weblogic.servlet.internal.ServletResponseImpl.setEncoding(ServletResponseI > > > mp > > > l.java:725) > > > at > > > > > > weblogic.servlet.internal.ServletResponseImpl.setLocale(ServletResponseImp > > > l. > > > java:261) > > > at > > > > > > org.apache.turbine.pipeline.DefaultTargetValve.execute(DefaultTargetValve. > > > ja > > > va:142) > > > at > > > > > > org.apache.turbine.pipeline.DefaultTargetValve.invoke(DefaultTargetValve.j > > > av > > > a:122) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invokeNext(TurbinePipeline.jav > > > a: > > > 223) > > > at > > > > > > org.apache.turbine.pipeline.DefaultActionValve.invoke(DefaultActionValve.j > > > av > > > a:148) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invokeNext(TurbinePipeline.jav > > > a: > > > 223) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invoke(TurbinePipeline.java:20 > > > 5) > > > at org.apache.turbine.Turbine.doGet(Turbine.java:282) > > > at org.apache.turbine.Turbine.doPost(Turbine.java:329) > > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) > > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > at > > > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.ja > > > va > > > :265) > > > at > > > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.ja > > > va > > > :200) > > > at > > > > > > weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServlet > > > Co > > > ntext.java:2456) > > > at > > > > > > weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.ja > > > va > > > :2039) > > > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) > > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) > > > rethrown as org.apache.turbine.TurbineException: Attempt to change > > > ContentType after calling getWriter() (cannot change charset > from 'null' > > > to > > > 'ISO-8859-1') > > > at > > > > > > org.apache.turbine.pipeline.DefaultTargetValve.invoke(DefaultTargetValve.j > > > av > > > a:127) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invokeNext(TurbinePipeline.jav > > > a: > > > 223) > > > at > > > > > > org.apache.turbine.pipeline.DefaultActionValve.invoke(DefaultActionValve.j > > > av > > > a:148) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invokeNext(TurbinePipeline.jav > > > a: > > > 223) > > > at > > > > > > org.apache.turbine.pipeline.TurbinePipeline.invoke(TurbinePipeline.java:20 > > > 5) > > > at org.apache.turbine.Turbine.doGet(Turbine.java:282) > > > at org.apache.turbine.Turbine.doPost(Turbine.java:329) > > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:760) > > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > > > at > > > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.ja > > > va > > > :265) > > > at > > > > > > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.ja > > > va > > > :200) > > > at > > > > > > weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServlet > > > Co > > > ntext.java:2456) > > > at > > > > > > weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.ja > > > va > > > :2039) > > > at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:139) > > > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120) > > > > > > > > > -----Original Message----- > > > From: Aaron Smuts [mailto:[EMAIL PROTECTED]] > > > Sent: Thursday, January 31, 2002 4:06 PM > > > To: Turbine Users List > > > Subject: RE: Please help. Content type: Sending pdf content to the > > > browser > > > > > > > > > You tried the buffered file server? > > > > > > Then you might need a PDF serving servlet so you have control. Sounds > > > funny. Can you send the entire class. > > > > > > > -----Original Message----- > > > > From: Aravinda Addala [mailto:[EMAIL PROTECTED]] > > > > Sent: Thursday, January 31, 2002 10:56 AM > > > > To: Turbine Users List > > > > Subject: RE: Please help. Content type: Sending pdf content to the > > > browser > > > > > > > > > > > > It doesn't actually work in Turbine 3 . > > > > All it output on the screen is the plain text of the FDF > > document(Adobe > > > > FDF > > > > api). > > > > > > > > Thanks for the reply. > > > > Aravinda > > > > > > > > > > > > > > > > -----Original Message----- > > > > From: Fabio Daprile [mailto:[EMAIL PROTECTED]] > > > > Sent: Thursday, January 31, 2002 2:51 PM > > > > To: Turbine Users List > > > > Subject: Re: Please help. Content type: Sending pdf content to the > > > > browser > > > > > > > > > > > > This is how i send files to the browser. > > > > All documents are stored in a table in MySql, in a blob field. > > > > For pdf files the content_type is "application/pdf". > > > > I use turbine 2. > > > > > > > > _attach = (Attachments)(_trans.getAttachmentss().elementAt(0)); > > > > > > > > _contentType = _attach.getContenttype() + ";name=" + "\"" + > > > > _attach.getFilename() + "\""; > > > > data.getResponse().setContentType(_contentType); > > > > data.getResponse().getOutputStream().write(_attach.getContent()); > > > > > > > > hope this can help you. > > > > > > > > Greetings. > > > > > > > > Fabio Daprile > > > > > > > > Aravinda Addala wrote: > > > > > > > > >Hi, > > > > > > > > > >I have read several postings about sending a different > content to the > > > > >browser. I am trying to generate a pdf using FDF in my > action. I get > > > the > > > > >content displayed as plain text. I tried many ways ( I had set the > > > > content > > > > >type both in Response and RunData objects in my action. > Also tried to > > > > use > > > > >data.setContentType in the template. Nothing worked). The same code > > > works > > > > >fine if I use that in a Servlet outside turbine. > > > > >I am using turbine 3. > > > > > > > > > >Please help. > > > > > > > > > >Thanks in advance. > > > > >Aravinda > > > > > > > > > > > > > > > > > > > >-- > > > > >To unsubscribe, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > > >For additional commands, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > > > > > W�rth Phoenix Srl > > > > Via Kravogl 4, I-39100 Bolzano > > > > Tel: +39 0471/564111 > > > > Fax: +39 0471/564122 > > > > > > > > mailto:[EMAIL PROTECTED] > > > > http://www.wuerth-phoenix.com > > > > > > > > > > > > > > > > > > > > -- > > > > To unsubscribe, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > > For additional commands, e-mail: > > > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > > > > > > > > -- > > > > To unsubscribe, e-mail: <mailto:turbine-user- > > > > [EMAIL PROTECTED]> > > > > For additional commands, e-mail: <mailto:turbine-user- > > > > [EMAIL PROTECTED]> > > > > > > > > > -- > > > To unsubscribe, e-mail: <mailto:turbine-user- > > > [EMAIL PROTECTED]> > > > For additional commands, e-mail: <mailto:turbine-user- > > > [EMAIL PROTECTED]> > > > > > -- > To unsubscribe, e-mail: > <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: > <mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
