• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MVC - Downloading a file created on the fly

 
Greenhorn
Posts: 17
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I am new to web development and am using the basic MVC-2 model for my web application. Hope someone can

guide me through this little problem I have explained below.

The user has some data on his page that is stored in bean.
The data is unique to every user.
The User should be able to download the data (with a specific format) as a file when he clicks on a

link.

The file is created on the fly.


What do I do in the controller and the model?


Thanks!

Raj.
 
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Controller:
  • Retrieve the bean's data from the request
  • Send bean's data to model
  • Retrieve new data from model
  • Put the appropriate headers into the response
  • Stream the new data into the response's output stream
  • Close the stream


  • Model
  • Obtain data
  • Process data
  • Return data


  • The model may not be needed, if all data is in the bean. A contrary scenario is if the bean held a product id and the model is needed to retrieve price, info and other information for that product (it would not be wise to store price in a session bean, because the user could edit that info).

    I feel like you asked me a really vague question, so I had to give you a vague answer (more). If you ask a specific question (with suggestions referenced in the link), I could probably help you more effectively.
    [ August 24, 2006: Message edited by: Rusty Smythe ]
     
    Sheriff
    Posts: 67747
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Another step:

  • Do this in a servlet not a JSP

  •  
    Rusty Smythe
    Ranch Hand
    Posts: 93
    Mac Objective C Ruby
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Bear Bibeault:

  • Do this in a servlet not a JSP


  • I suppose a MVC purist could argue that a servlet is not sufficiently Model 2, because the formatting is bound up in the other code.

    Maybe the formatting could be handled by a XSLT, so that is kept free of java code.
     
    Rajashekar Subramany
    Greenhorn
    Posts: 17
    Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks!! This helps alot... and i guess I have sometime to go before I fiddle around with XSLT
     
    reply
      Bookmark Topic Watch Topic
    • New Topic