• Post Reply Bookmark Topic Watch Topic
  • New Topic

Jsp With XML  RSS feed

 
Sanjay Deshpande
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to run through the XML file in my jsp file.
WHich way is better?JDOm or SAX?
In which case JDom should be used and In which case SAX?
Any example of creating XML file with a Database Query?
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
<code>
DECLARE
Ctx DBMS_XMLQuery.ctxType;-- Var's to convert SQL output to XML
xml clob;
emp_id NUMBER := '10000478';
xmlc varchar2(4000);-- Var's required to convert lob to varchar
off integer := 1;
len integer := 4000;
BEGIN
Ctx := DBMS_XMLQuery.newContext('SELECT * FROM emp WHERE emp_id = :empid');
DBMS_XMLQuery.setBindValue(Ctx, 'empid', emp_id);
xml := DBMS_XMLQuery.getXML(Ctx);
DBMS_XMLQuery.closeContext(Ctx);
DBMS_LOB.READ(xml, len, off, xmlc); -- Display first part on screen
DBMS_OUTPUT.PUT_LINE(xmlc);
END;
</code>
This would generate a xml from the DB query.
JDOM doesn't use parser factory..This is an API which sits between the application and the XML parser and allows the application to choose a parser.DOM and SAX are APIs define the proerties of XML.JDOM by itself is not a parser.It allows an application to choose xerces or IBM's parser..
Geeta
 
Sanjay Deshpande
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx Geeta,
After reading u r valuable code , what i understand is this :
I will have to write a Sp to generate XML file.
Then using SAX or something i will have to read and display this XML.
Is this rite?
Plz let me know.
Is there any other way also?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP Standard Template Library has tags for dealing with XML formatted data. Do a search at Yahoo for JSTL and you will see plenty of references.
Bill
 
Geeta Ramasami
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If u don't want ur BE to generate the XML, then in ur FE(JSP or servlets) retrive the Data from the back end and build the XML..Then as usual use any of the parsers to parse it..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!