aspose file tools*
The moose likes Web Services and the fly likes Reterive JSON Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Reterive JSON " Watch "Reterive JSON " New topic
Author

Reterive JSON

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi

I have the URL through which my jsp hit the web service which in return gives me the JSON Object. This web service use the BASIC Authentication. I want to send username & password also at the time hitting that service, so it wil not prompt to enter username and password. Can you please provide me the simplest way to achieve this.

Thanks.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

How are you sending the request to the web service? Please TellTheDetails.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi

I have very less understanding about web services. Going through few silly codes of java script to get the json object which are not working yet.
I have 2 things : 1) URL of Web service (provided by third party) 2) Username &r password for authentication.
When manually in put the web service url in browser it print the json object on browser. But Not getting how to do the same thing through jsp.

Will be thankful if you help me to start.

Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61658
    
  67

You still have not answered my question. Are you using Java code in the JSP to make the request, or Ajax in the JavaScript? Or something else. We cannot help you if you do not provide details.
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi, I am using ajax in javascript. Below is the sample code that i am trying:


Nothing happens on browser when i run this html.
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

vivek dhiman wrote:Can you please provide me the simplest way to achieve this.

Try with jQuery like this:

vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Can we do it in JavaScript. After some try.

Alert1 shows nothing, Alert2 shows nothing and Alert3 shows null. Any Advice.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42640
    
  65
Here's some good advice: don't use XMLHttpRequest directly, use a library like jQuery instead, like surlac showed you. You'll save much time in the process, and have a more stable and more maintainable solution in the end.


Ping & DNS - my free Android networking tools app
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi updated code is below, but nothing happens when i run.


Still it not showing any result.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42640
    
  65
Is the send_with_ajax() method being called? Are there any JavaScript errors in the error console?
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Yes, its getting call. Also if i don't use but use . Browser showing loading.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42640
    
  65
Yes, its getting call.

How did you make sure of that?

Also:
Are there any JavaScript errors in the error console?
vivek dhiman
Ranch Hand

Joined: Aug 05, 2011
Posts: 130

Hi

To check i am using alert()..I cleared the console & then hit jsp again & when ctrl+shift+j it doesn't shows any error on console
And i am using only for jquery.
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

vivek dhiman wrote:I cleared the console & then hit jsp again & when ctrl+shift+j it doesn't shows any error on console

Try something like firebug to show simple network data, and WireShark or TCPMon for more advanced things.
Santhosh ayiappan
Ranch Hand

Joined: Jan 30, 2007
Posts: 80

Open Chrome, Press F12 and then invoke your Java Script code that you have written to consumes the webservice. Under the Network tab, you can see what happened to your service call.

Regards
Santhosh
surlac surlacovich
Ranch Hand

Joined: Mar 12, 2013
Posts: 296

vivek dhiman, any progress on that?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reterive JSON