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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how to access resource file(html, text) outside war
 
Similar Threads
How to encode image in parts?
display html in jsp using struts action
BLOB(image) -> ByteArrayOutputStream -> display on screen
Image & Stream in JSP
how to show html page