Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File merging

 
Raghav Mathur
Ranch Hand
Posts: 641
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
anybody ?
 
damien malone
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • 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
  • 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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic