Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HTML file...

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i call html file in a servlet?
I want to read the html content stored in a file and want that as a servlet output. How should I do it?
Thanks
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to get all the contents of the HTML file, why not just use the include() method in the RequestDispatcher interface? Is there something you are trying to gain by reading the file in and writing it back out?
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to get the contents of the file (which is a part of the HTML file, that was generated by parsing the XML document) and redirect to the brower.
ie
out.println("<html>");
out.println("<body>");
:
:
//here read the contents of the file.html, which contains a html //table, redirect that content to the browser
:
:
out.println("</body>");
out.println("</html>");

I tried,
response.sendRedirect("c:\file.html");
It is just displaying the contents of file but not the other html tags which I have written before and after I read the file.
How do you use RequestDispatcher, please give me some pointers...
Thanks
 
maha anna
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jairat,
I use it like this.

I responded to your another post of same question. Which approach are you going to take. This ,.include technique also would work.
regds
maha anna
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic