• Post Reply Bookmark Topic Watch Topic
  • New Topic

Xml output Print in Browser

 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here I try to access two third party API i got two xml response so i merge that in single file and make store in local system,if i print output in console means it gives xml format output but i want to print in browser it won't work please help me to find solution i post my code here


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "it doesn't work." Does it throw an exception? Display the wrong output? Do something unexpected like download the file?
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means it display only text output without xml tags.i want to display xml file format in browser
 
Paul Clapham
Sheriff
Posts: 21871
36
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be correct to assume that you are using a browser to observe the result of that code? (You were kind of vague, only saying "it display".)

I don't see you telling the browser to expect XML anywhere in that code. So probably the browser is expecting HTML, and ignoring any elements which it doesn't recognize. You might consider using the browser's "view page source" to see what the browser actually gets, as opposed to how it interprets what it gets.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya i agree what you saying, so it is not recognize my xml file ,means there is no other way to display my xml file in browser

* actually what i need is i want to send this xml file to client (phonegap) , there i actually parse the xml so am using jquery ajax function

* inside of jquery-ajax i use sucess: function(data)-receive my xml file from servlet


* it is possible any other way to send my xml file to my client
 
Paul Clapham
Sheriff
Posts: 21871
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Durga Roobini wrote:ya i agree what you saying, so it is not recognize my xml file ,means there is no other way to display my xml file in browser


Sure, you just have to set the content type appropriately.

actually what i need is i want to send this xml file to client (phonegap) , there i actually parse the xml so am using jquery ajax function


In which case you don't actually need to deal with the browser at all. So stop worrying about the browser because it isn't part of your problem.

it is possible any other way to send my xml file to my client


That IS the way to send the XML to the client, assuming that the request came from the client. You're just confused because you happened to choose a bad tool to test with.

 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
* in my first case i have to set, response.setcontenttype("text/xml"); please check my above codings and tell me where i correctly insert this code,even i try this three places alternatively it wont work
* tell me the way or some samples to send xml file to client from servlet
 
E Armitage
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, explain what you mean by 'it won't work'. Did you write the client part that is supposed to read that xml? Did you get an error on the phonegap application when you tried to readthe XML? Or what happened exactly?
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it wont work means it gives only text output but not xml format output
in client side using


$.support.cors = true;

$.ajax({
type: "GET",
url: 'http://10.0.2.2:8080/sucess/ThirdServlet',
data:{
val:val,
},
dataType: "xml", //here am using datatype:text means it print text from servlet output else it returns null value
success: function(data) //it goin in sucess part
{
// i print data here it returns null because my servlet browser have text but above i mention datatype:xml so it returns null [so only i want xml output in browser means client side problem will clear]
/// parsing xml codings
},
error:{.....},

});
please help me soon am struck here long time
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!