Hi ,
I have to complete a file uploading module, in this module I am sending request from form.html to put_file.jsp by action and using jquery i am trying to access the state of the upload. for this purpose I am using session variable and this session variable is updated as the file upload is in progress. (basically a while loop which transfers the bytes). Now using ajax jquery get calls i want the session variable and on the form.html i want to display the status of the uploading. can you please let me know how can i do that.
my approach:
home.html --> form for uploading the files with a jquery script
<script language="javascript">
$(document).ready(function(){
alert('document level');
$("#submitID").click(function(){
alert('button click level');
ajaxfunction1();
});
});
function ajaxfunction(){
alert('Function level');
$.ajax({
type:
"get",
url:
"getajax_file.jsp",
data:
"type=get",
success:
function(msg) {
if(msg=="0")
{
$("#result").html("<h3> uploading ... </h3>")
.fadeIn("slow");
window.setTimeout("ajaxfunction()",100);
}
else
{
return;
}
}
});
}
<BODY>
<form id="myForm" method="post"
action="put_file.jsp" > <!-- onsubmit="ajaxFunction()">-->
<input type="text" name="txtFile" id="txtFile" /><br />
<input type="submit" id="submitID" name="submit" value="calculate" />
</form>
<p id="result"></p>
</BODY>
So basically the put_file.jsp has the code for the uploading of the file and the getajax_file.jsp has the out.println(session.getAttribute("listener"));
and the put_file.jsp
has \
session.getAttribute("listener","0");
while(not all bytes transfer){
session.getAttribute("listener","0");
}
session.getAttribute("listener","1");
so is this a correct approach