validating existance of file on the server
My application requires certain files to be uploaded by the user to the server. I am intending to validate the process, that is: if the user has not uploaded the files or the files are not on the server then a prompt message should be displayed asking the user to upload required files.
Can we embed JSP in Java script ? I was thinking using "onsubmit" tag in my html form and pointing it to a validation function in java script. In java script I may use JSP tag for finding out the existance of a certain file.
For instance, checkFile can be a method written in JSP tags as:
<%!
public String checkFile()
{
File ch3 =new File("path/file name") ;
if (ch3.exists() ==true)
{
return f3 ;// file found
}
else
return f3not ;// file not found
}
%>
and then within java script i may call the method checkFile() as:
function validate_file ( )
{
valid =true;
f3 ="ftn03" ;
if ("<%= checkFile() %>" != f3)
{
alert("Please upload the required files") ;
valid =false;
}
return valid;
}
I don't think I can use JSP tags within Java script. Can anyone suggest something, or point me in some direction ?
Thanks
Message was edited by:
NasirMunir

