• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to show html page

 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do i show the html page which is out of web context?
If i have a test.html in c: drive, how do i display it?
The following link is not working.

I have a link
<a href="file:///c:/test.html">click here</a>


Thanks
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Of course that's not going to work except on the machine on which the file is located.

Either move the file to where the web server can find it, or write a servlet to stream the file.
 
Rajan Chinna
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the file is located on the same machine, still it doesn't work.

I use the following stream method in the jsp, but it is not displaying the html properly.
--------------------------
response.setContentType("text/html");
File file = new File("c:/test.html");
FileInputStream in = new FileInputStream(file);
OutputStream os=response.getOutputStream();
byte[] buf = new byte[4096];
int count = 0;
while ((count = in.read(buf)) >= 0)
{
os.write(buf, 0, count);
}
os.flush();
in.close();
os.close();
--------------------------
 
Bear Bibeault
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but it is not displaying the html properly.



That doesn't give us very much to go on.

I would also highly highly and did I mention, HIGHLY, recommend that you do this in a servlet rather than a JSP.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rajan Chinna:
the file is located on the same machine, still it doesn't work.



I think what Bear meant was that the file would need to be on the same machine as the browser which, of course would be absurd.

What errors are you getting while trying to stream the file from your servlet?
[ May 10, 2005: Message edited by: Ben Souther ]
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

Not seeing any reason why this stream example wouldn't work, I implemented it verbatim and, believe me, it worked both in the localhost and in a remote host. So, unless your html page is faulty (did you try to see it direct from the filesystem?) it should work for you too.

Cesar
 
Rajan Chinna
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using the above code i can stream any ordinary html, but my html is generated from jasperreports. I got to set some parameter before it generate the report, this is to align the content properly.

Anyway Thanks for the info guys. I solve this issue.
 
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic