displaying a physical webpage with frames in iframe
- by ksa
i have iframe in my webpage, i have done the coding part for browsing the folders and viewing files in iframe.each folder has a index.html.now i need to display the index.html in iframe.index.html page contains frames divided into 2,each from different sources.i tried to display a sample webpage without frames and it was a success,page with frames spoils the party.
my code for getting the html file
<%
String path=request.getParameter("name");
File directory = new File(path);
FileFilter fileFilter=new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().endsWith("html");
}
};
File[] files = directory.listFiles(fileFilter);
for (int index = 0; index < files.length; index++)
{
String s= files[index].getName();
String s1=files[index].getAbsolutePath();
%>
<a href="fileview?name=<%=s1%>" target="sss"><%=s%></a>
<%
}
%>
mycode for displaying the page in iframe.
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
String name=req.getParameter("name");
res.setHeader("Content-Disposition", "inline; filename=\""+name+"\"");
java.io.FileInputStream fis=new java.io.FileInputStream(name);
int i;
while((i=fis.read())!=-1)
{
out.write(i);
}
fis.close();
out.close();
}