This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How to implement XML in Web App Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to implement XML in Web App" Watch "How to implement XML in Web App" New topic
Author

How to implement XML in Web App

Lisa Modglin
Ranch Hand

Joined: Oct 28, 2003
Posts: 46
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
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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)


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
...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).
Pho Tek
Ranch Hand

Joined: Nov 05, 2000
Posts: 761

In addition to the two uses suggested by Lasse; you could also create user interfaces in XML. Check out xulplanet


Regards,

Pho
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
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 ?


Spritle Software Blogs
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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
Bartender

Joined: Jul 13, 2001
Posts: 3150
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.
Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
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
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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 ]
Jan Jani
Ranch Hand

Joined: Feb 05, 2004
Posts: 35
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
Ariel Valentin
Ranch Hand

Joined: Jan 30, 2004
Posts: 44
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


A. Valentin
Lisa Modglin
Ranch Hand

Joined: Oct 28, 2003
Posts: 46
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
 
wood burning stoves
 
subject: How to implement XML in Web App
 
Similar Threads
setting Timezone for web application
sending jar file in a binary SMS
Google Hosting
General Doubt in web & app server
XML Examples