It's was just a suggestion.  I've been bitten in the past when I
wasn't consistant in my design or I didn't follow patterns.  Mostly
with maintenance.  It's made me more of a purist when it comes to
patterns.

To clarify, the Action doesn't build the byte[] array.  It would
retrieve it from a utility class or business component.  It's job is
to place it in request scope and forward to the Servlet.

It's a great idea to move Nick's code to a utility class.  Putting
that code in an Action certainly would be a bad idea.  Action classes
are controllers and shouldn't directly handle business logic or
building a response to the client.  This would directly couple your
application logic to the Stuts framework.  (Last couple sentences
meant for newbies reading this thread).


-- 
Virtually,
Andre Van Klaveren
Architect III, SCP
Enterprise Transformation Services
Unisys Corporation



On 4/27/05, Brian McGovern <[EMAIL PROTECTED]> wrote:
> Well i guess thats technically correct but arguably if my action is 
> delegating control flow by validating the user is who he says he is before 
> showing the pdf to him.  He can be bounced to 3 other screens via this action 
> class and I don't see much difference in using the action to stream back 
> response or creating a byte[] or refernce to the File and storing in request 
> scope.
> 
> Ive achieved reuse by dumping a modified version of Nick's handy method in a 
> utility class that I'll be reusing on other projects.
> So while i agree with you on principle, i think this might be one of those 
> cases where in practice its a better idea to stray from stringent mvc pattern.
> 
> But I'm just a hack. :)
> -B
> 
> -----Original Message-----
> From: Andre Van Klaveren [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 26, 2005 4:51 PM
> To: Struts Users Mailing List; Nick Heudecker
> Subject: Re: PDF Streamed To Client
> 
> Brian,
> 
> While Nick's solution certainly works, it doesn't follow best
> practices, MVC in particular (No offense Nick).  Technically a view
> component such as a Servlet or JSP should be responsible for writing
> the response back to the client.  The Action is responsible for flow
> control and interacting with business components.
> 
> I solved a similar problem by having the Action place a byte array of
> the PDF content and the content type (as a String) in request scope
> and forwarding to a Servlet.  The Servlet's (called
> BinaryOutputServlet) sole purpose is to retrieve the content and
> content type from request scope and stream it back to the client.
> This is where Nick's example code would fit nicely.
> 
> Now, in your case you would probably put a reference to the PDF file
> in request scope instead of a byte array, especially if the PDF
> documents are large.  In my case the content was relatively small and
> was generated dynamically.
> 
> If you design the Servlet generically it can be reused in any project
> that requires the application to stream the content of any type of
> file to the client (gif, jpg, rdf, etc).
> 
> --
> Virtually,
> Andre Van Klaveren
> SCP
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to