473,396 Members | 2,026 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to get http response from Java Servlet

245 100+
Hi geeks,
We made a Java Servlet which takes 3 parameters and upload files from source path to remote path. The three parameters are password, source path and destination path.

When we run this command
http://localhost:8080/FTPSClientServ/uploader?password=xxxxxx&local=D:\xampp\htdocs\ews \nyc\data\&remote=/Vanguard/fromVanguard/msd/
on http browser it works perfectly fine and gives http response.

Now i want to run this commmand in php document. I tried to execute that command in php document by making an ajax call it returns status 200 but along with it it gives an exception and does not give the http response.
The exception is
uncaught exception: [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.send]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: http://localhost/ews/nyc/test.php :: getGridlist :: line 43" data: no]
Here is my code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     define("DESTINATION_PATH","/Vanguard/fromVanguard/msd/");
  3.     $spassword = "xxxxxxx";
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7.     <head>
  8.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9.         <title>NYC</title>
  10.         <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
  11.  
  12.         <script type="text/javascript">
  13.  
  14.             var objXMLHttp;
  15.             function GetXmlHttpObject(){
  16.                 objXMLHttp=null;
  17.                 try{
  18.                     // Firefox, Opera 8.0+, Safari
  19.                     objXMLHttp=new XMLHttpRequest();
  20.                 }
  21.                 catch (e){
  22.                     // Internet Explorer
  23.                     try{
  24.                         objXMLHttp=new ActiveXObject("Msxml2.XMLHTTP");
  25.                     }
  26.                     catch (e){
  27.                         try{
  28.                             objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP");
  29.                         }
  30.                         catch (e){
  31.                             jAlert('Please upgrade your browser','No AJAX Support');
  32.                             return false;
  33.                         }
  34.                     }
  35.                 }
  36.                 return objXMLHttp;
  37.             }
  38.  
  39.         var src_path="D:\\xampp\\htdocs\\ews\\nyc\\data\\";
  40.         var xmlGridList=null;
  41.         function getGridlist(){
  42.             xmlGridList=GetXmlHttpObject();
  43.             url="http://localhost:8080/FTPSClientServ/uploader?password=<?=$spassword;?>&local="+src_path+"&remote=<?=DESTINATION_PATH;?>";
  44.  
  45.             xmlGridList.open('GET', url, false);
  46.             xmlGridList.onreadystatechange = $makeGrid;
  47.             xmlGridList.send();
  48.         }
  49.         function $makeGrid(){
  50.             if(xmlGridList.readyState==4){
  51.                 if(xmlGridList.status==200){
  52.                     alert(xmlGridList.responseText);
  53.                 }else{
  54.                     alert('An error occoured on the server the details are below <br />'+xmlGridList.status+'  '+xmlGridList.statusText);
  55.                 }
  56.             }
  57.         }
  58.         </script>
  59.     </head>
  60.     <body onload="javascript:getGridlist();"></body>
  61. </html>
  62.  
How can i get the http response in this technique. if this is not a validate way then what is the other way to do that?
Awaiting of your response.
Thanks in Advance,
Mohsin Rafique
Dec 26 '10 #1
2 4057
Dormilich
8,658 Expert Mod 8TB
if you include jQuery, why not using its AJAX functions?
Dec 26 '10 #2
omerbutt
638 512MB
it is giving exception at the point httt.send(null) if used get method with asynchronos=false or true it is not getting the responsetext although the status shows 200 against the call in firebug
this was the case with jquery too
do you think that servlet also need to be configured properly to return the http response headers

note that it is uploading the file but not getting back the response , the guy who sent programmed the servlet told us that you need to have synchronus communication with the servlet where as AJAX is asynchronus ,
but we are experiencing it for the first time ,
and that Java guy is not avaiabe at the moment , although i think thats a blunder what he said that ajax could not communicate with the servlet i have seen alots of examples in the last 1 hour of searching that people are using jquery to call the servlet and return the response from the servlet
what you think ....it would be alot more beter if a running example could be located only a simple one that could show how to do it .....i also read somewhere that we need to set the WWW-Authenticate headers in the AJAX call too but all these things are confusing until a simple running example could be seen and understood
regards,
Omer Aslam
Dec 26 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Chris Morgan | last post by:
I'm trying to get php to run on my webserver as a Java Servlet, it works the first time but fails the second time and crashes the JVM with the following error: I have tried the latest versions...
6
by: alan | last post by:
Dear all, I have a servlet problem. When I modified my java servlet program and then uploaded it to my web hosting server, then I start my web browser(I.E) to see the result. But it loaded...
1
by: Vasil Slavov | last post by:
I apologize for the long email. I hope somebody will have time to read it and give some suggestions. I am working on a school project written in Python (using mod_python) and I need to upload a...
3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
3
by: ppcguy | last post by:
i've got a progress bar that tracks a process running on a server (java servlet). i know i can refresh the page and update the status...but this results in the page being redrawn everytime. ...
1
by: Kevin Schneider | last post by:
I am trying to POST an XML string to a Java servlet, but I am getting the error "The underlying connection was closed: An unexpected error occurred on a receive." when I try to get the response....
1
by: Vimala Sri | last post by:
Hello all, Have a great day. I wish to made interaction from c program in unix to the java servlet. That is i want to send a request from the Unix c program to the servlet. ...
7
by: judge82 | last post by:
please I am learning how to use servlet. here is my code package TestWebApp; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; public class...
2
by: dmstn | last post by:
Hey! I've got a little problem. I have to make a web site for a university essay. I curently have to create a search engine. Users can enter a hotel name in a search bar and results have to appear in...
8
by: inpuarg | last post by:
I 'm developing a c# (.net 2.0) windows forms application and in this application i want to connect to a java servlet page (HTTPS) (which is servlet 2.4 and which may be using Web Based SSO Sun...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.