File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes Need Suggestion for following sceneario Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "Need Suggestion for following sceneario" Watch "Need Suggestion for following sceneario" New topic

Need Suggestion for following sceneario

sakthi moorthy
Ranch Hand

Joined: Oct 17, 2007
Posts: 54
HI Guys,

I need suggestion for the following scenario
1) There are X number of word Documents saved in a hard disk
2) In Web application upon some action
2.1) the logged in user details has to be fetched from database
2.2) the User details(userId,UserName,Desigantion (hardly some 9 informations)) has to be filled in one of the documents, which has been mentioned in the Step 1.
3) Generate the PDF with the modified content and send it to browser for download.

1) Load All the documents into memory as a String or StringBuffer format while application server start up & replace(fill userid, userName and some information) the String or String Buffer & Generate the PDF
2) Load only the requested or specific document as a String or StringBuffer format & replace the String or String Buffer & Generate the PDF
3) Take the contents of word as constants of String Objects and create java program for generating the PDF.

I Think the first two approach will give OutOfMemoryException if everything gets loaded into memory, The Third approach will be performance impact because of more String operations.

how to do it in efficient way.

Thanks & Regards

Fernando Franzini
Ranch Hand

Joined: Jan 09, 2009
Posts: 489

Hello sakthi
It is not allowed in the forums offer design suggestions. As an architect you have to consider all available options to resolve the situation, make your choice and justify why.

Fernando Franzini - Java Blog
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33129

As an aside, you wouldn't use StringBuffer in a new app. You'd use StringBuilder instead. (If it even needs to be a string - look at CLOBs and ascii streams)

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Need Suggestion for following sceneario
jQuery in Action, 3rd edition