print "Content-type: text/html\n\n"; print ""; print ""; print qq{}; print ""; print ''; print ''; print qq{
Java return value will be'; listed here.
}; print ""; print ""; The javascript file is located in the cgi-bin dir on my linux machine running Apache. I have chmod 755 so it can be executed. The Java script is as followed: 1. var xmlHttp 2. function showName(str) 3. { 4. xmlHttp=GetXmlHttpObject() 5. if (xmlHttp==null) 6. { 7. alert ("Browser does not support HTTP Request") 8. return 9. } 10. var url="ncbi.cgi" 11. url=url+"?q="+str 12. url=url+"&sid="+Math.random() 13. xmlHttp.onreadystatechange=stateChanged 14. xmlHttp.open("GET",url,true) 15. xmlHttp.send(null) 16. } 17. function stateChanged() 18. { 19. document.getElementById("geneName").innerHTML = "Fetching XML file..." 20. if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 21. { 22. var response = xmlHttp.responseText 23. if (!response) { 24. document.getElementById("geneName").innerHTML="No data returned!" 25. } 26. else { 27. document.getElementById("geneName").innerHTML=response 28. } 29. } 30. } 31. function GetXmlHttpObject() 32. { 33. var xmlHttp=null; 34. try 35. { 36. // Firefox, Opera 8.0+, Safari 37. xmlHttp=new XMLHttpRequest(); 38. } 39. catch (e) 40. { 41. // Internet Explorer 42. try 43. { 44. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 45. } 46. catch (e) 47. { 48. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 49. } 50. } 51. return xmlHttp; 52. } #### #! /usr/bin/perl $temp=$ENV{'QUERY_STRING'}; $test_path = "/var/www/html/test_file/"; # separate each keyword foreach ( split( /&/, $temp ) ) { # separate the keys and values ( $key, $val ) = split( /=/, $_, 2 ); # translate + to spaces $key=~s/\+/ /g; $val=~s/\+/ /g; # translate %xx codes to characters $key=~s/%([0-9a-f]{2})/pack("c",hex($1))/gie; $val=~s/%([0-9a-f]{2})/pack("c",hex($1))/gie; } $file = $test_path . $val; $out = $test_path . $key; open FH, ">out"; print FH "I am here"; close FH; open FH, "$val" or die "Can not open for read: $val"; my $pid = ; close FH; print $pid;