RE: PDF File Display in JSP-Struts
>>> [EMAIL PROTECTED] 11/14/03 7:21 AM >>> > The question that Abhijeet asked was how to do it > in a JSP. I agree that doing this is a kludge. > > Regards, > Jarrod Lugo ...and the answer was: "You can not and should not do it in a jsp." - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
The question that Abhijeet asked was how to do it in a JSP. I agree that doing this is a kludge. Regards, Jarrod Lugo -Original Message- From: Larry Meadors [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 3:09 PM To: [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts Why would you ever do this? This looks like a complete and total kludge. If you are sending back binary data (application/pdf), just do it from the action class using the response.getOutputStream() and return null from the execute method. Advantages: - you already have everything you need right there - you eliminate the entry in struts-config - you eliminate a useless jsp - you can specify any content type (not just one per jsp) - you get better exception handling - the list could go on and on... Larry >>> [EMAIL PROTECTED] 11/12/03 11:43 AM >>> It may be an issue with using white space inside your jsp. I normally do something like this (using a custom fo to pdf bean)... (note: everything up to, and including, the is on one line) <%@ page contentType="application/pdf" %><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %> Regards, Jarrod Lugo -Original Message- From: David Gagnon [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 1:24 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts It's not the Internet Explorer problem with pdf ? Check http://xml.apache.org/fop/servlets.html#ie Let me know ... I can give clue on how I solved it. /David -Message d'origine- De : Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Envoyé : 10 novembre, 2003 07:55 À : Struts Users Mailing List Cc : WebSphere User Group Tech Q & A Forum Objet : PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PDF File Display in JSP-Struts
"I remember in the pre-Struts days of someone on the JSP Interest mailing list talking about the fact that they had a 5000 line JSP page that implemented the entire app (complete with creating different forms and processing the results) -- all in a single page. And he was *proud* of it!" Doesn't he still post to this list under the alias Vic C.? >>> [EMAIL PROTECTED] 11/12/2003 7:03:13 PM >>> Quoting Christian Bollmeyer <[EMAIL PROTECTED]>: > Am Mittwoch, 12. November 2003 21:31 schrieb Craig R. McClanahan: > > Quoting Larry Meadors <[EMAIL PROTECTED]>: > > > Why would you ever do this? This looks like a complete and total > > > kludge. > > > > > > If you are sending back binary data (application/pdf), just do it > > > from the action class using the response.getOutputStream() and > > > return null from the execute method. > > > > > > Advantages: > > > - you already have everything you need right there > > > - you eliminate the entry in struts-config > > > - you eliminate a useless jsp > > > - you can specify any content type (not just one per jsp) > > > - you get better exception handling > > > - the list could go on and on... > > > > There's actually a much more fundamental reason than all of the above > > (which are true nonetheless) -- JSP pages are not allowed to create > > binary output. They never call response.getOutputStream(). > > That's how it's meant to be, and JSPs themselves don't, but you > can always shed in a scriptlet to make them behave otherwise. You might get lucky on some containers, but you can be assured that writing binary output from a scriptlet is not guaranteed to be portable. Indeed, you're more likely to cause an IllegalStateException, because the servlet container won't let you call getWriter() and getOutputStream() on the same response. > I've seen people doing just ridiculous things with JSPs, some > of them routinely putting a <% at the top and a %> at the end, > and then went on happily putting everything imaginable in-bet- > ween, usually with lengthy <%@ page import="[xy]" %> state- > ments on top. Won't support Mark Galbreath on this matter, > so if there may be a grain of truth in his direction, I'm still > just telling from my personal experiences, limited to a > single case, thankfully. But never underestimate human > ingenuity ;-) > s/ingenuity/foolishness/ :-) I remember in the pre-Struts days of someone on the JSP Interest mailing list talking about the fact that they had a 5000 line JSP page that implemented the entire app (complete with creating different forms and processing the results) -- all in a single page. And he was *proud* of it! > > > Larry > > > > Craig > > -- Chris. > Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Any time he has to fix a bug or add a new feature, he knows exactly which file to edit ;-) -Original Message- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 9:03 PM To: Struts Users Mailing List Subject: Re: PDF File Display in JSP-Struts >>>>> I remember in the pre-Struts days of someone on the JSP Interest mailing list talking about the fact that they had a 5000 line JSP page that implemented the entire app (complete with creating different forms and processing the results) -- all in a single page. And he was *proud* of it! >>>>>
Re: PDF File Display in JSP-Struts
Quoting Christian Bollmeyer <[EMAIL PROTECTED]>: > Am Mittwoch, 12. November 2003 21:31 schrieb Craig R. McClanahan: > > Quoting Larry Meadors <[EMAIL PROTECTED]>: > > > Why would you ever do this? This looks like a complete and total > > > kludge. > > > > > > If you are sending back binary data (application/pdf), just do it > > > from the action class using the response.getOutputStream() and > > > return null from the execute method. > > > > > > Advantages: > > > - you already have everything you need right there > > > - you eliminate the entry in struts-config > > > - you eliminate a useless jsp > > > - you can specify any content type (not just one per jsp) > > > - you get better exception handling > > > - the list could go on and on... > > > > There's actually a much more fundamental reason than all of the above > > (which are true nonetheless) -- JSP pages are not allowed to create > > binary output. They never call response.getOutputStream(). > > That's how it's meant to be, and JSPs themselves don't, but you > can always shed in a scriptlet to make them behave otherwise. You might get lucky on some containers, but you can be assured that writing binary output from a scriptlet is not guaranteed to be portable. Indeed, you're more likely to cause an IllegalStateException, because the servlet container won't let you call getWriter() and getOutputStream() on the same response. > I've seen people doing just ridiculous things with JSPs, some > of them routinely putting a <% at the top and a %> at the end, > and then went on happily putting everything imaginable in-bet- > ween, usually with lengthy <%@ page import="[xy]" %> state- > ments on top. Won't support Mark Galbreath on this matter, > so if there may be a grain of truth in his direction, I'm still > just telling from my personal experiences, limited to a > single case, thankfully. But never underestimate human > ingenuity ;-) > s/ingenuity/foolishness/ :-) I remember in the pre-Struts days of someone on the JSP Interest mailing list talking about the fact that they had a 5000 line JSP page that implemented the entire app (complete with creating different forms and processing the results) -- all in a single page. And he was *proud* of it! > > > Larry > > > > Craig > > -- Chris. > Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PDF File Display in JSP-Struts
>>> [EMAIL PROTECTED] 11/12/03 3:14 PM >>> Am Mittwoch, 12. November 2003 21:31 schrieb Craig R. McClanahan: > Quoting Larry Meadors <[EMAIL PROTECTED]>: > > Why would you ever do this? This looks like a complete and total > > kludge. > > > > If you are sending back binary data (application/pdf), just do it > > from the action class using the response.getOutputStream() and > > return null from the execute method. > > > > Advantages: > > - you already have everything you need right there > > - you eliminate the entry in struts-config > > - you eliminate a useless jsp > > - you can specify any content type (not just one per jsp) > > - you get better exception handling > > - the list could go on and on... > > There's actually a much more fundamental reason than all of the above > (which are true nonetheless) -- JSP pages are not allowed to create > binary output. They never call response.getOutputStream(). >That's how it's meant to be, and JSPs themselves don't, but you >can always shed in a scriptlet to make them behave otherwise. But that is the point - Why would you? It is like using a screwdriver as a hammer because you like screwdrivers. > I've seen people doing just ridiculous things with JSPs, some >of them routinely putting a <% at the top and a %> at the end, >and then went on happily putting everything imaginable in-bet- >ween, usually with lengthy <%@ page import="[xy]" %> state- >ments on top. Won't support Mark Galbreath on this matter, >so if there may be a grain of truth in his direction, I'm still >just telling from my personal experiences, limited to a >single case, thankfully. But never underestimate human >ingenuity ;-) Heheh, you will sometimes see stupidity coming disguised as ingenuity - beware! Larry - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: PDF File Display in JSP-Struts
Am Mittwoch, 12. November 2003 21:31 schrieb Craig R. McClanahan: > Quoting Larry Meadors <[EMAIL PROTECTED]>: > > Why would you ever do this? This looks like a complete and total > > kludge. > > > > If you are sending back binary data (application/pdf), just do it > > from the action class using the response.getOutputStream() and > > return null from the execute method. > > > > Advantages: > > - you already have everything you need right there > > - you eliminate the entry in struts-config > > - you eliminate a useless jsp > > - you can specify any content type (not just one per jsp) > > - you get better exception handling > > - the list could go on and on... > > There's actually a much more fundamental reason than all of the above > (which are true nonetheless) -- JSP pages are not allowed to create > binary output. They never call response.getOutputStream(). That's how it's meant to be, and JSPs themselves don't, but you can always shed in a scriptlet to make them behave otherwise. I've seen people doing just ridiculous things with JSPs, some of them routinely putting a <% at the top and a %> at the end, and then went on happily putting everything imaginable in-bet- ween, usually with lengthy <%@ page import="[xy]" %> state- ments on top. Won't support Mark Galbreath on this matter, so if there may be a grain of truth in his direction, I'm still just telling from my personal experiences, limited to a single case, thankfully. But never underestimate human ingenuity ;-) > > Larry > > Craig -- Chris. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Quoting Larry Meadors <[EMAIL PROTECTED]>: > Why would you ever do this? This looks like a complete and total kludge. > > If you are sending back binary data (application/pdf), just do it from the > action class using the response.getOutputStream() and return null from the > execute method. > > Advantages: > - you already have everything you need right there > - you eliminate the entry in struts-config > - you eliminate a useless jsp > - you can specify any content type (not just one per jsp) > - you get better exception handling > - the list could go on and on... > There's actually a much more fundamental reason than all of the above (which are true nonetheless) -- JSP pages are not allowed to create binary output. They never call response.getOutputStream(). > Larry > Craig - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Why would you ever do this? This looks like a complete and total kludge. If you are sending back binary data (application/pdf), just do it from the action class using the response.getOutputStream() and return null from the execute method. Advantages: - you already have everything you need right there - you eliminate the entry in struts-config - you eliminate a useless jsp - you can specify any content type (not just one per jsp) - you get better exception handling - the list could go on and on... Larry >>> [EMAIL PROTECTED] 11/12/03 11:43 AM >>> It may be an issue with using white space inside your jsp. I normally do something like this (using a custom fo to pdf bean)... (note: everything up to, and including, the is on one line) <%@ page contentType="application/pdf" %><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %> Regards, Jarrod Lugo -Original Message- From: David Gagnon [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 1:24 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts It's not the Internet Explorer problem with pdf ? Check http://xml.apache.org/fop/servlets.html#ie Let me know ... I can give clue on how I solved it. /David -Message d'origine- De : Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Envoyé : 10 novembre, 2003 07:55 À : Struts Users Mailing List Cc : WebSphere User Group Tech Q & A Forum Objet : PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
It may be an issue with using white space inside your jsp. I normally do something like this (using a custom fo to pdf bean)... (note: everything up to, and including, the is on one line) <%@ page contentType="application/pdf" %><%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"; %> Regards, Jarrod Lugo -Original Message- From: David Gagnon [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 12, 2003 1:24 PM To: Struts Users Mailing List; [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts It's not the Internet Explorer problem with pdf ? Check http://xml.apache.org/fop/servlets.html#ie Let me know ... I can give clue on how I solved it. /David -Message d'origine- De : Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Envoyé : 10 novembre, 2003 07:55 À : Struts Users Mailing List Cc : WebSphere User Group Tech Q & A Forum Objet : PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Are you using the jsp writer, or the servlet output stream? JSP writer assumes char data and totally borks the pdf. SOS assumes binary data. Larry === Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
It's not the Internet Explorer problem with pdf ? Check http://xml.apache.org/fop/servlets.html#ie Let me know ... I can give clue on how I solved it. /David -Message d'origine- De : Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Envoyé : 10 novembre, 2003 07:55 À : Struts Users Mailing List Cc : WebSphere User Group Tech Q & A Forum Objet : PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
The better approach would be to set the proper mime type in the action itself...So that u dont put any restrictions on jsps then...And any how, if you are writing the pdf to output stream, why you still want to forward to a jsp? Why not return a null forward in that case? -Original Message- From: Nail, Evan Burke [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 2:17 PM To: Struts Users Mailing List Subject: RE: PDF File Display in JSP-Struts Also, You have to make sure that nothing is written out to the stream before you set your content type. Also I did this just playing around a while back, I noticed that we had to move our jsp imports to the bottom of the file. Having them at the top caused errors in the output. I'm guessing for the above reason. If you have to use a jsp page, make sure all you do in the page is set the content type and output the content stream. bn -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 7:10 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts Are you setting the mime type properly on the response object? -Original Message- From: Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 1:55 PM To: Struts Users Mailing List Cc: WebSphere User Group Tech Q & A Forum Subject: PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This e-mail is the property of Enron Corp. and/or its relevant affiliate and may contain confidential and privileged material for the sole use of the intended recipient (s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender or reply to Enron Corp. at [EMAIL PROTECTED] and delete all copies of the message. This e-mail (and any attachments hereto) are not intended to be an offer (or an acceptance) and do not create or evidence a binding and enforceable contract between Enron Corp. (or any of its affiliates) and the intended recipient or any other party, and may not be relied on by anyone as the basis of a contract by estoppel or otherwise. Thank you. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Also, You have to make sure that nothing is written out to the stream before you set your content type. Also I did this just playing around a while back, I noticed that we had to move our jsp imports to the bottom of the file. Having them at the top caused errors in the output. I'm guessing for the above reason. If you have to use a jsp page, make sure all you do in the page is set the content type and output the content stream. bn -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 7:10 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: PDF File Display in JSP-Struts Are you setting the mime type properly on the response object? -Original Message- From: Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 1:55 PM To: Struts Users Mailing List Cc: WebSphere User Group Tech Q & A Forum Subject: PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** This e-mail is the property of Enron Corp. and/or its relevant affiliate and may contain confidential and privileged material for the sole use of the intended recipient (s). Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender or reply to Enron Corp. at [EMAIL PROTECTED] and delete all copies of the message. This e-mail (and any attachments hereto) are not intended to be an offer (or an acceptance) and do not create or evidence a binding and enforceable contract between Enron Corp. (or any of its affiliates) and the intended recipient or any other party, and may not be relied on by anyone as the basis of a contract by estoppel or otherwise. Thank you. ** - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: PDF File Display in JSP-Struts
Are you setting the mime type properly on the response object? -Original Message- From: Abhijeet Mahalkar [mailto:[EMAIL PROTECTED] Sent: Monday, November 10, 2003 1:55 PM To: Struts Users Mailing List Cc: WebSphere User Group Tech Q & A Forum Subject: PDF File Display in JSP-Struts Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
PDF File Display in JSP-Struts
Hi All, I want to display one PDF file in my websphere struts framework. when i do it without struts (only servlets ) it works but when i use JSP along with struts it does not work. it does not read binary data properly... Is there any body to help me out regards & thankx in advace... Abhijeet Mahalkar - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]