This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why JAXB ?

 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning JAXB, I know it could convert data between java and XML. But in real world, what is usage for this API ?

1. Why will we need to convert java to XML ? storage ? No, we could directly save data into relational database.

2. Why will we need to convert XML to java ? In J2EE, if we have XML data, then we could directly generate page using JSTL xml tag.

I don't know if the higher level API, like Hibernate, is using JAXB ? Or java web service is using it in the lower level. Maybe this is only usage. But for regular developer, JAXB has nothing usage.

If I am wrong, please correct me.

Thanks.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1. Why will we need to convert java to XML ? storage ? No, we could directly save data into relational database.


XML is easily portable and can be used interoperability between systems. sometimes it can be used as common protocol to 2 different system communicate.


I know it could convert data between java and XML. But in real world, what is usage for this API ?


Well say your application receives inbound XML from various systems and you need to do some calculations and store certain values to DB. you should probably use JAXB to convert XML to java objects and retrieve the objects to perform operations and store it in DB.
 
Hong Anderson
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Examples use cases:
  • Export model to XML
  • Import XML to model


  • Anyway, you don't need to use JAXB, you can use any Java-XML mapping tools.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic