• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to implement XML in Web App

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I recently used XML to create pdf documents. I no longer have that type of application requirement but I really enjoyed working with XML. What are some other ways I can use XML in a simple web application? My web app is written in Java, servlets, jsp pages and the database is Oracle9i. I want to expand my experience, but don't know what task I can use XML to solve.
Lisa
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my experience, the two most common ways of using XML in a J2EE application are
1) Configuration file format (very handy, got to admit -- I'm doing this myself)
2) Integration with external systems (web services, proprietary XML messaging)
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and if your application wouldn't be too simple, some folks make their application produce XML output and have a Filter which runs the outgoing XML through XSL transformation (into HTML, XHTML, WML, what have you).
 
Ranch Hand
Posts: 782
Python Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In addition to the two uses suggested by Lasse; you could also create user interfaces in XML. Check out xulplanet
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
1) Configuration file format (very handy, got to admit -- I'm doing this myself)


Lasse, my question may sound stupid, but what is advantage of using XML instead of .properties files escp for configurations ?
At the end both file formats were easy to understand, can be changed during runtime, .properties file is more easier to read than XML files, platform independent, can be bundled with jar file.. etc.,
Am i missing something ?
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Balaji Loganathan:
Lasse, my question may sound stupid, but what is advantage of using XML instead of .properties files escp for configurations ?

It's true that both can be changed at runtime, bundled in a .jar file, are human-readable, etc.
The main reasons why I went for XML in my current project were:
1) The configuration file can become very complex, with an unknown number of certain type of entries. I've seen .properties files with all sorts of "prefix" based grouping solutions and all I can say is "yuck".
2) XML provides validation capabilities that I would need to code myself for a .properties file based solution
 
Balaji Loganathan
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:
It's true that both can be changed at runtime, bundled in a .jar file, are human-readable, etc.
The main reasons why I went for XML in my current project were:
1) The configuration file can become very complex, with an unknown number of certain type of entries. I've seen .properties files with all sorts of "prefix" based grouping solutions and all I can say is "yuck".
2) XML provides validation capabilities that I would need to code myself for a .properties file based solution


That makes sense, thanks lasse.
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where can I find a good tutorial on writing some code that will read a xml file I use as a property file? I have have the hardest tiem with xml and finding examples of stuff that I want to do. I tried to simply read a String variable that contained all xml and I could not get it to work with Dom or Sax and had to end up using something called NanoXML. I got the job done, but I felt really terrible becasue I could not get it to work with the other two. It has been a really fustrating process. Hopefully I will win a copy of Elliot's book. I have his Java Network programming book from a while back and all I can say is that is was very useful. I have another Orielly book on Java & XML and I cannot say the same...
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anthony, are you aware of the Java Developer's Almanac? For example, this sample shows how you can parse an XML file into an instance of org.w3c.dom.Document using the DOM API.
Our very own wiki also contains some helpful code snippets.
[ February 25, 2004: Message edited by: Lasse Koskela ]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use it for the security purpose,you have web.xml in j2ee this file is the heart of j2ee and this file uses XML

~Jani
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What are some other ways I can use XML in a simple web application? My web app is written in Java, servlets, jsp pages and the database is Oracle9i. I want to expand my experience, but don't know what task I can use XML to solve.


In situations with many users accessing dynamic information you want to minimize the number of DB calls/connections to improve performance, XML is super handy
1. just query the DB info once and a while, instead of for every user accessing the site
2. save the data in an XML file (like cache for your webapp)
3. parse the XML File!
Hope that helps
 
Lisa Modglin
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is probably a little late, but wow! thanks for all of the ideas. I use the web.xml regularly, since my application is a Java app. And, I do query the database constantly!
Lisa
 
reply
    Bookmark Topic Watch Topic
  • New Topic