• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How and where to use xml

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody, I am Krishna, I don't know can I ask this question here.

I am reading xml since days and I am unable o understand what for it is used. can anybody tell me where in real time I use xml.

All I know is, a client will send a request and server will process the request, issue a query to database and retrieve the dara and print the data to the response and send the web page to client. This is time consuming, so server will retrieve the data from database in xml file format and send it to the client. Now using javascript client will parse the xml file and show the data.

Is this correct?

And one more thing is when I was searching to learn AJAX, on some web pages I saw this code



After that the client will stripeoff the name tag and represent the data. My question is why can't the serve directly send the data like


I saw some code like this in some sites

<?xml version="1.0"?>


who is going to write this document, is it the database or the programmer. If the programmer has to write this code, then what about if another par is introduced, how many times the programmer has to change the xml document. or if the server retreives the data from database in xml format then how it is going to send the file from server to client. how the javascript opens the file.

Can anybody please help me with XML, I reffered w3schools and many more sites, but I didn't understood where and how can I use XML.

Thank you all in advance. Have a nice day.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you are confused about the usage of AJAX in web applications.

All I know is, a client will send a request and server will process the request, issue a query to database and retrieve the dara and print the data to the response and send the web page to client. This is time consuming, so server will retrieve the data from database in xml file format and send it to the client. Now using javascript client will parse the xml file and show the data.

Is this correct?



Not entirely correct. But assuming you are asking this question in the context of AJAX - it's mainly about asynchronous requests. You will find a lot of documentation around AJAX, through a quick search. This gives a quick overview (the "Rationale" section in there will answer some of your questions).
 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Jaikiran, acutally I wasn't able to explain my doubt, no problem, I will give a try again.

I wrote a AJAX code such that it contacts the server and retrieves a xml file named books, suppose in future if few more books are added, then ultimately the xml file must be changed by the programmer, suppose if daily few books are added then what about the xml file.

So what I want to do is, I will call a jsp, which will connect to database, then retrieve the data in xml file, then I will send this xml file to client, the AJAX code will parse the xml file and represent the data.

Is this possible? calling a jsp then retrieving a xml file, and representing the data, is this possible? If possible please tell me where can I find the complete solution, why because I am unable to find this is any site.

Thank you in advance. Have a nice day.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

krishna anusha wrote:I wrote a AJAX code such that it contacts the server and retrieves a xml file named books, suppose in future if few more books are added, then ultimately the xml file must be changed by the programmer, suppose if daily few books are added then what about the xml file.


No, of course the programmer isn't sitting next to the server and typing the XML. There would be some code on the server which generates the XML based on some data it gets from somewhere.

So what I want to do is, I will call a jsp, which will connect to database, then retrieve the data in xml file, then I will send this xml file to client, the AJAX code will parse the xml file and represent the data.

Is this possible? calling a jsp then retrieving a xml file, and representing the data, is this possible? If possible please tell me where can I find the complete solution, why because I am unable to find this is any site.


Actually you left out some steps there. It's not likely your code will retrieve XML from the database. More likely it will retrieve ordinary data from the database and construct an XML document from that data. Then yes, you would return that XML document as the response and the AJAX code would deal with it.

The other step you left out is, you wouldn't do most of that in a JSP. You would do the data extraction in a servlet and then forward to the JSP, which would generate XML from the data.

So yes, of course it's possible. But if you were hoping to find a complete solution on the internet, you aren't going to find that. You will certainly find tutorials on various topics, like database processing and XML and so on. But there aren't people out there writing tutorials on combinations of three or more topics, like you were hoping.

 
krishna Karthikk
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Paul, now I understood something, but there is still some confusion, but I have a program without any servlet, as a beginner and just for simulation I wrote this in a jsp page, please don't mind. Here is the code and the objective is to find the existence of an employee id. If employee id already exists false is returned, otherwise true is returned.

Here is the select_id.jsp page.

Can you tell me how to use xml here. Please just tell me the model. I will be very thankful to you and thanks in advance. Have a nice day.
 
reply
    Bookmark Topic Watch Topic
  • New Topic