aspose file tools*
The moose likes Other Application Frameworks and the fly likes how to access resource file(html, text) outside war Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "how to access resource file(html, text) outside war" Watch "how to access resource file(html, text) outside war" New topic
Author

how to access resource file(html, text) outside war

swapnil kataria
Ranch Hand

Joined: Feb 26, 2011
Posts: 64
I want to access a file which is on application server, but not the part of war.
I tried it using file handling, it works fine, but don't know how efficient it will be,
can someone have some idea of doing it easily

FileInputStream file = new FileInputStream(filePath);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
int i = 0;
while ((i = file.read()) != -1) {
byteArrayOutputStream.write(i);
}
response.setContentType("text/html");
response.setHeader("Content-Disposition",
"inline; myfile.html");
response.setContentLength(byteArrayOutputStream.size());
ServletOutputStream outputStream = response.getOutputStream();
byteArrayOutputStream.writeTo(outputStream);
outputStream.flush();
outputStream.close();
byteArrayOutputStream.close();
file.close();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to access resource file(html, text) outside war
 
Similar Threads
display html in jsp using struts action
How to encode image in parts?
Image & Stream in JSP
how to show html page
BLOB(image) -> ByteArrayOutputStream -> display on screen