• Post Reply Bookmark Topic Watch Topic
  • New Topic

MVC - Downloading a file created on the fly  RSS feed

 
Rajashekar Subramany
Greenhorn
Posts: 17
Java
  • Mark post as helpful
  • send pies
  • 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.
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • 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 ]
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 66154
    146
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • 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
    • 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
    • Quote
    • Report post to moderator
    Thanks!! This helps alot... and i guess I have sometime to go before I fiddle around with XSLT
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!