Hi
I want to copy files from one folder to folder when i click on hyperlink in my jsp.For that i used scriptlet code in javascript function.But it is executed when
jsp body is loading.
Below is my code.Please help me to resolve this?
<html>
<head>
<script type="text/javascript">
function copyjscssfile()
{
alert("onclick event in if..filename ");
<%
File srcdir = new File(tabimpldir);
File src = new File(tabimpldir+"/jsp/stylesheets/myOwn");
File dest = new File(tabimpldir+"/jsp/stylesheets/smdasari");
if(src.isDirectory())
{
File[] listfiles=src.listFiles();
for(int i=0;i<listfiles.length;i++)
{
try {
if(dest.exists())
{
File destfile=new File(dest,listfiles[i].getName());
System.out.println("Copy.main() srcfile"+listfiles[i].getName()+" destfile"+destfile);
InputStream in =new FileInputStream(listfiles[i]);
OutputStream outs = new FileOutputStream(destfile);
byte[] buffer =new byte[1024];
int len=0;
while ((len = in.read(buffer)) > 0) {
outs.write(buffer, 0, len);
}
in.close();
outs.close();
}
}
catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
%>
}
</script>
</head>
<body>
copycssFiles
</body>
</html>