• 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

File merging

 
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
anybody ?
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
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

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

Hope that helps you a bit, sorry if this reply seems a bit hurried.
Damien
 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks
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 .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic