File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes File merging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "File merging" Watch "File merging" New topic

File merging

Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
I have to print 2 reports in 2 diff formats so for what i have created is 2 textfiles compirsing of 2 different HTMls , which effectively means that there are 2 diff designs. I have also hardcoded jsp variables in the textfile only ... now
There is my jsp which reads from the textfile1 (the frist design) Also it makes a connection to the db and extracts the values to be printed . e.g
Sting Idno = "";
String name="";
String sex="";
I make a connection and get the values , store them in theses varibles. Now what i wish to do is to read the text file , get the html content( with the hardcoded jsp variables which are same as the ones declared in the jsp)
So the net effect would be that i get a report format and my jsp variables just overwrite the ones extraxted from the text file which also mean that i did not have to wite the html part for my report. Can anybody help me achieving this task.
I hope i am clear enough .
Thanks in advance

Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
anybody ?
damien malone
Ranch Hand

Joined: May 06, 2003
Posts: 35
I dont think you will be able to dymanically create teh jsp page like that. What I would do is have javascript variables instead of jsp ones. Read in the content of the text file (using the classloader so it will also work if deployed as a war) and populate the javascript variables at teh top of your page,
So your jsp would look like this

var variable1 = <%=variable you want the value of%>;
Then here you would output the html contained in your text file
And your html would have something like
<h1>Person name <javascript ocument.write(variable1)></h1>

Hope that helps you a bit, sorry if this reply seems a bit hurried.
Raghav Mathur
Ranch Hand

Joined: Jan 12, 2001
Posts: 641
I guess i found an alternative of reading from files ...
Why not make diff methods and call the class in the jsp ... what that class will contain would be 4 different methods for generating 4 diff types of report formats.
The method would return to me a String comprising of the html i want ( report format). Whatever i shall pass to the method would be printed.
i tried it and it worked the way i wasnted it to work
Thanks anyways .
I agree. Here's the link:
subject: File merging
It's not a secret anymore!