• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reterive JSON

 
vivek dhiman
Ranch Hand
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you sending the request to the web service? Please TellTheDetails.
 
vivek dhiman
Ranch Hand
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vivek dhiman wrote:Can you please provide me the simplest way to achieve this.

Try with jQuery like this:

 
vivek dhiman
Ranch Hand
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can we do it in JavaScript. After some try.

Alert1 shows nothing, Alert2 shows nothing and Alert3 shows null. Any Advice.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
vivek dhiman
Ranch Hand
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi updated code is below, but nothing happens when i run.


Still it not showing any result.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the send_with_ajax() method being called? Are there any JavaScript errors in the error console?
 
vivek dhiman
Ranch Hand
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, its getting call. Also if i don't use but use . Browser showing loading.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 152
Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 80
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 296
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vivek dhiman, any progress on that?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic