save result to text file in JSP

J

Jason

Hi, all,
I have a JavaServer Page which get data from database then display it for user
to review; and now, how can I have a button somewhere in the result page which
let user save current result to a text file.

fo example, below is what user will see from a web browser:
- - - - - - - - - - - - - - - - -
field1 | field2 | field 3 |
- - - - - - - - - - - - - - - - -
A101 |A201 |A301 |
- - - - - - - - - - - - - - - - -
B101 |B201 |B301 |
- - - - - - - - - - - - - - - - -

output file:
result.txt
field1,field2,field3
A101,A201,A301
B101,B201,B301

Thanks in advance.
Jason
 
C

Chris Smith

Jason said:
I have a JavaServer Page which get data from database then display it for user
to review; and now, how can I have a button somewhere in the result page which
let user save current result to a text file.

Since you just said that you've tied your database access to the JSP,
you'd have to rewrite the database access code to do this.

The better solution, though, would be to write the code to access the
database in a Java class, and have it return the data in some kind of
straightforward data structure. You could then call that code, and
store the result in the session; and then the JSP could display it as a
web page, and the button could submit to a servlet which sends back the
data in a text format.

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top