Hello,
We have a text area in the webpage( JSP ) which needs to be populated from the client side
text file. The client / end user needs to select a file on click of button.
We have attached a HTML code which works fine as a standalone page.
It gives the following error when the same page is opened from the webserver
The error message is "Automation server cannot create object( Line 16 ).
We have tried this in Tomcat as well as J2EE.
If any one has developed or tried reading a client side text file from the
webserver page ( JSP ) please either mail your suggestion or code snippet.
Since the application is developed for Windows as well as Unix platforms we do not wish to
use Active X controls.
<code>
<head>
<script language="javascript" src="common.js">
</script>
<script language="javascript">
function readFile(f_foManip,f_taToRead){
f_foManip.value="";
f_foManip.click();
if(f_foManip.value!="") {
var l_fileExtn = f_foManip.value.substr(f_foManip.value.length-4,4);
if(l_fileExtn!=".txt"){
alert("Invalid File");
return;
}
var myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
var newStream = myActiveXObject.OpenTextFile(f_foManip.value,1);
var l_strRead = newStream.readAll();
f_taToRead.value = f_taToRead.value + l_strRead;
newStream.close();
}
}
</script>
</head>
<body>
<input type="file" name="foManip" STYLE="position:absolute; left:-100; top:-100">
<textarea name="taName" cols="30" rows="10"></textarea>
<input type="button" value="Read File" onClick="readFile(foManip,taName);">
</body>
</code