Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

viewing HTML page saved on the server from the browser

843841Jan 6 2006 — edited Jan 9 2006
Hi all

In my application i am having some HTML pages saved on the server. I had given an option to the user to view the HTML page from my application. behind the scene what i am doing is that the view request will get handled by a servlet and from that servlet iam locating the HTML page on the server directory and sending the HTML page to browser by using the Servlet OutputStream. The HTML page is shown on the browser but the attached images are not shown. The images are also there in the server directory and are refered in the HTML file correctly. When i directly open the HTML file then the images are shown correctly.
Can anyone suggest wat's wrong there.

The code i m using is

ServletOutputStream out=response.getOutputStream();
if(format.equalsIgnoreCase("pdf"))
{
logger.info("Seleted format is pdf..\n");
response.setContentType("application/pdf");
}
else
{
logger.info("Seleted format is html..\n");
response.setContentType("text/html");
}
String file = ReportingConstants.URL_GENERATEDREPORTS+reportPath+itemName;
// file : HTML file absolute path as string.
URL url=new URL(file);
BufferedInputStream bis=new BufferedInputStream(url.openStream());
BufferedOutputStream bos=new BufferedOutputStream(out);
byte[] buff = new byte[2048];
int bytesRead;

while(-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
bos.write(buff, 0, bytesRead);
bos.flush();
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 6 2006
Added on Jan 6 2006
2 comments
147 views