How Do I Turn A JSP Screen Into A File?

M

MattC

I have a fairly complex jsp screen that contains 5 tabs and a few
hundred data elements. The customer wants me to take the data on the
screen, put it in a file and send it to them via web services. The
information does not have to be formatted in the same way as it is on
the screen but that is desirable. I am looking for options on how to
accomplish this.

One way is to just build a file programmatically totally separate from
the jsp. That will work but certainly doesn't seem to be an easy way
and in addition I will have to keep the data file in sync with any
changes made to the jsp.

Is there an easier way to accomplish this by using the http response or
some other cleaver approach?

Any ideas are appreciated.
 
D

Dave Glasser

I have a fairly complex jsp screen that contains 5 tabs and a few
hundred data elements. The customer wants me to take the data on the
screen, put it in a file and send it to them via web services. The
information does not have to be formatted in the same way as it is on
the screen but that is desirable. I am looking for options on how to
accomplish this.

One way is to just build a file programmatically totally separate from
the jsp. That will work but certainly doesn't seem to be an easy way
and in addition I will have to keep the data file in sync with any
changes made to the jsp.

Is there an easier way to accomplish this by using the http response or
some other cleaver approach?


Presumably your data elements live inside a database, or a file, or
some other source and the JSP page uses them to dynamically build the
HTML. If that's the case, it seems the simplest thing to do would be
to build a web service that reads the data from its original source,
rather than scraping the HTML.

If, OTOH you're saying that the data actually lives inside the JSP
file -- for example, the JSP file contains a list of items for sale,
and if the price of one is changed, you have to physically edit the
JSP file -- then you have a real mess on your hands. I would advise
you to separate the data from the presentation. If putting it into a
database isn't practical, put it into a simple text file, for example
a CSV (comma-separated values) file, which both the JSP and the web
service would read.


--
Check out QueryForm, a free, open source, Java/Swing-based
front end for relational databases.

http://qform.sourceforge.net

If you're a musician, check out RPitch Relative Pitch
Ear Training Software.

http://rpitch.sourceforge.net
 
A

Andrea Desole

MattC said:
One way is to just build a file programmatically totally separate from
the jsp. That will work but certainly doesn't seem to be an easy way
and in addition I will have to keep the data file in sync with any
changes made to the jsp.

Is there an easier way to accomplish this by using the http response or
some other cleaver approach?

you are probably on the right way when you talk about building a file
programmatically. This is what you can do.
You use a servlet filter. In the filter you replace the original servlet
response with your own response wrapper. The getWriter() method of your
wrapper will give your own PrintWriter, which will write everything to
the PrintWriter of the original reponse (wrapped by your wrapper) and to
your separate file.
Of course, if you do this you will lose all the information about
stylesheets and pictures, which are on different files. You will just
write the html coming from your jsp.
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top