XMLDataSet and Dynamic XML using JSP

I am trying to use the XMLDataSet function to call a jsp page
instead of an xml file. The jsp page fetches records out of a db
and creates xml to return to the spry function. Nothing seems to be
returned, and blank spry data region on page.
If i supply a xml file to the function it works correctly.
I adapted the ASP/PHP samples from XMLExport demo. Code as
follows:- If i run 2nd jsp directly, the browser shows the xml as
expected.
--- TEST.JSP ---
<script type="text/javascript">
Spry.Data.Region.debug=true;
var dsPeople = new Spry.Data.XMLDataSet("transtoxml.jsp",
"company/person");
</script>
--- transtoxml.jsp ---
<%@ page language="java"
import="java.sql.*, java.io.*, java.util.*,
com.Ostermiller.util.*"
errorPage="" %>
<%@ include file="globals.jsp" %>
<%
String SQL="";
Statement sTransaction;
ResultSet rTransaction;
try
Class.forName(className);
con =
java.sql.DriverManager.getConnection(connectionURL,userName,password);
}catch(Exception e){
out.print(e.toString());
out.print("Error connecting to database " + connectionURL);
SQL ="SELECT ";
SQL+="[ID], ";
SQL+="[DocumentNo]";
SQL+="FROM TRX_TRANSACTION_MAPPING";
sTransaction = con.createStatement();
try {
rTransaction = sTransaction.executeQuery(SQL);
response.setContentType("text/xml");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("pragma","no-cache");
%>
<?xml version='1.0' encoding='iso-8859-1'?>
<company>
<% while(rTransaction.next()) { %>
<person>
<id><%=(rTransaction.getString("ID"))%></id>
</person>
<% } %>
</company>
<%
response.flushBuffer();
sTransaction.close();
} catch (SQLException e) {
out.print(e);
%>

This is the xml output the jsp gives when run directly:- Cut
n pasted from browser. There does appear to be an error, because
the spry:state="error" div is being displayed. If i paste the
following into a file all is ok, any ideas anyone.
regards
sm@rt
<?xml version="1.0" encoding="iso-8859-1" ?>
- <company>
- <person>
<id>117</id>
</person>
- <person>
<id>118</id>
</person>
- <person>
<id>119</id>
</person>
- <person>
<id>120</id>
</person>
- <person>
<id>121</id>
</person>
- <person>
<id>122</id>
</person>
- <person>
<id>123</id>
</person>
- <person>
<id>124</id>
</person>
- <person>
<id>125</id>
</person>
- <person>
<id>126</id>
</person>
- <person>
<id>127</id>
</person>
- <person>
<id>128</id>
</person>
- <person>
<id>129</id>
</person>
- <person>
<id>130</id>
</person>
- <person>
<id>131</id>
</person>
- <person>
<id>132</id>
</person>
- <person>
<id>133</id>
</person>
- <person>
<id>134</id>
</person>
- <person>
<id>135</id>
</person>
- <person>
<id>136</id>
</person>
- <person>
<id>137</id>
</person>
- <person>
<id>138</id>
</person>
- <person>
<id>139</id>
</person>
- <person>
<id>141</id>
</person>
</company>

Similar Messages

  • How to create two level dynamic list using JSP , Java Script and Oracle

    I am new in JSP. And i am facing problem in creating two level dynamic list using JSP ,Java Script where the listdata will come from Oracle 10g express edition database. Is there any easy way in JSP that is available on in ASP.NET.
    Plz response with details.

    1) Learn JDBC API [http://java.sun.com/docs/books/tutorial/jdbc/index.html].
    2) Create DAO class which contains JDBC code and do all SQL queries and returns or takes ID's or DTO objects.
    3) Learn Servlet API [http://java.sun.com/javaee/5/docs/tutorial/doc/].
    4) Create Servlet class which calls the DAO class, gets the list of DTO's as result, puts it as a request attribute and forwards the request to a JSP page.
    5) Learn JSP and JSTL [http://java.sun.com/javaee/5/docs/tutorial/doc/]. Also learn HTML if you even don't know it.
    6) Create JSP page which uses the JSTL c:forEach tag to access the list of DTO's and iterate over it and prints a HTML list out.
    You don't need Javascript for this.

  • Creating XML using JSP

    Hi I want to create a xml using JSP For eg I want to create a report
              and I want to take all the data required for the report from the user
              and want to put all the information in a session and whenever a user
              wants to see the html output I should be able to parse the xml file
              and show it to user.
              I know it is doable but I am confused about storing the data in
              session and concerting that data into XML file any help would be
              great.
              Thanks,
              Preeti
              

    Sounds like you might want to look at XML data binding. Something like JAXB
              or Castor can create an object that can be turned into XML by merely calling
              a single method and probably streamed to Xalan or whatever to create HTML.
              However, don't quote me on this - I am having enough troubles with trying to
              get the compiled Objects to be as I wish. Basically, they both take your
              DTD with an extra file that defines the types to be used in the classes -
              i.e. instead of string int might be used - and which tags to turn into
              classes and general information such as this about the output of your
              classes. You then simply call Unmarshal (for both castor and JAXB) and it
              loads the file from the selected input stream into the created object, you
              edit the object, what ever - store it on the server... and call Marshal to
              get back the xml... as this is all using streams it could be passed to Xalan
              for processing i think...
              Hope I've helped, and answered your question a little!
              "Preeti Sikri" <[email protected]> wrote in message
              news:[email protected]...
              > Hi I want to create a xml using JSP For eg I want to create a report
              > and I want to take all the data required for the report from the user
              > and want to put all the information in a session and whenever a user
              > wants to see the html output I should be able to parse the xml file
              > and show it to user.
              >
              > I know it is doable but I am confused about storing the data in
              > session and concerting that data into XML file any help would be
              > great.
              >
              > Thanks,
              > Preeti
              

  • Cancel- and main-button dynamically generated using JSP-pages

    Maybe a HOWTO for the Jdev-team.
    HOWTO get rid of the delete and main-button in your jsp-pages?
    Very simple!
    Go to the container_bottom.jsp page in your webapp/jsp-folder and delete the code for the cancel-button => now the user can render his own buttons by using a header.html, contents.jsp and footer.html for the jsp-pages.

    We tried the same thing you are trying to do and got
    very far, but it quickly became very complicated. We
    realized it was just simpler to use the screenflow as
    intended.
    By this I mean, if your parent form has 4 buttons
    (A,B, C and SUBMIT), you should design different
    paths in your screen flow for each button. so when a
    user clicks button A, the parent form submits back to
    Fuego engine, engine looks at screenflow and send
    them down the button A path to the Form A. When they
    hit submit on Form A, screenflow goes back to parent
    form.Hi, bcespinola:
    Our team finally decide use jsp with YUI (Yahoo User Interface Library) to achieve this design. Wish this could help you. All popup window would be replaced by Dialog of YUI. Thanks for your help.
    Vince

  • How to send/receive XML using JSP

    Hi,
    I'm new to all this JSP/XML stuff so apologies if this is trivial.
    I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?
    Once the XML has been sent, how do you use JSP to request the XML file? I've figured out how to parse it already.
    Also, is it possible to call xsql directly within JSP?
    Thanks!

    I'm trying to send an XML file via HTTP POST using JSP. Anyone know how to do this?The question is, does anybody understand what you mean by this. Let me take a guess. You want to upload an XML file to a server. If this guess is right, then the answer is don't use JSP to do that. JSP is for generating output to be sent to a client. Use a servlet to handle an upload. And you don't need to write it yourself, there are already several file-upload servlets available on the web.
    Second guess: you have a POST request that asks your server to send an XML file back to the client. If it's a static XML file you don't need a JSP or a servlet or anything, just let your web server handle it just like any other static file. If it's dynamically generated then there's an answer worth giving, but I doubt that this is your question. But if it is, let us know.

  • Dynamic select using jsp?

    grrrrr............ok so I'm kinda new to this, and just a little frustrated. I'm gonna ramble here, so any time I sound like I don't know what I'm talking about it 's because I don't..correct me. I want to include a bean in a jsp which will buil d a dynamic select box on the fly. That is, connect to an LDAP db and place each value returned in the query in a select box. Now, I can compile and run the bean in my IDE and watch the output in the console. It's correct because I see "<select><option value = hall>hall....</select>". In the buildSelectBox() method I'm using System.out.println to display each line of my select box (is that right?). Now, when I copy the .class file over to the server I was initially getting an error because the bean wasn't found. I resolved that by properly compiling the bean in a package. Problem is that if I call the bean.buildSelect() method in the .jsp nothing comes back. The page is left blank. What in the world is that about? Can someone push me toward a tutorial that can push me in the right direction or sumthin? Why am I having so much trouble with this? Should I be building the select on the jsp?
    regards,
    mat

    Hi!
    If i understand you correctly :-) you are doing not very right things. I don't want it to seem like I'm going to teach you, but:
    The Bean that has buildSelect() method is not a bean at all. Usualy Beans contain getter/setters and accumulate data. If you want to build html code dynamicaly then you should use servlets(Which is not very flexible in your situation, I think), not JSPs. And if you are using JSPs then you have to make Tag which will do this everything.
    Other way is to use Struts framework which is very good and flexible for building web applications - it has it's own tags for many cases. You can make loops in JSPs, use beans and all that stuff.
    Guys will correct me if I missed something.
    Good luck

  • Reading XML using JSP

    Hi,
    My company just bought a software, which this s/w will generate a HTML file with the XML tags and data inside it.
    I will need to read the XML tags and data inside the HTML file using JSP.
    Does anyone know how to do this?
    Please help mi!!Thanks!

    http://java.sun.com/webservices/docs/1.1/tutorial/doc/index.html

  • How can I send request to the server through XML using JSP

    How can I send XML request to the server using JSP and servlets

    Ajax may be the one way.

  • How to get a dynamic pages using jsp?

    actually using jsp we create static pages.
    My question is whether it is possible to create dynamic pages. ie the page should reflect changes without refreshing or reloading. for example we have date timings frequently updated without refreshing

    Read Beginning JSP from WROX Press. It is a good book for developing dynamic JSP using all latest technologies.

  • Dynamic combobox using jsp

    HI All,
    This is very urgent for me please help me to come out of this.
    I just want to display the values in combobox from database using jsp,but i have difficulty in doing it can any one help me for this.I will be thankfull if any one gives me a code for the same.
    Ramesh.R

    very simple example
    <%@ page import="java.sql.*" %>
    Add Item:
    <SELECT NAME="item">
    <ol>
    <%
    Connection con5 =
    DriverManager.getConnection("url","user","password");
    String q5 = "query" ;
    Statement stmt5 = (Statement)con5.createStatement();
    ResultSet rs5 = stmt5.executeQuery(q5);
    while(rs5.next()){
    String str5= rs5.getString("field");
    %>
    <li> <% out.print("<OPTION>" + str5); %>
    <% } %>
    </ol>
    </SELECT>

  • Create XML using JSP

    I am trying to create and send an XML file back to browser where XSL will be
              applied. I am using wl6.0 sp2
              I tried like this
              <%@ page contentType="text/xml" %>
              <%
              out.println("<?xml version=\"1.0\"?>") ;
              out.println("<books>");
              out.println("<title>") ;
              out.println("XML Programming") ;
              out.println("</title>") ;
              out.println("</books>") ;
              %>
              But the browser is blank.
              Thanks
              shaikjava
              

    Also, valid XML documents have no whitespace before the <?xml ...?>
              declaration.
              Sam
              "Cameron Purdy" <[email protected]> wrote in message
              news:[email protected]...
              > There are lots of reasons why the browser could be blank. Judging from the
              > JSP you provided below, I could not even begin to guess at what you are
              > doing to prevent the browser from working.
              >
              > > <%
              > > out.println("<?xml version=\"1.0\"?>") ;
              > > out.println("<books>");
              > > out.println("<title>") ;
              > > out.println("XML Programming") ;
              > > out.println("</title>") ;
              > > out.println("</books>") ;
              > > %>
              >
              > Do you mean you did all that when you could have just:
              >
              > <?xml version="1.0"?>
              > <books>
              > <title>
              > XML Programming
              > </title>
              > </books>
              >
              > That is what JSPs are for, after all!!! Don't put markup language inside
              > code inside a JSP!!! You're going to give someone a friggin heart attack.
              >
              > Remember:
              > servlets = code
              > jsps = raw content
              >
              > You can put content in servlets by embedding it in the code. You can put
              > code in jsps by embedding it in the content.
              >
              > Peace,
              >
              > --
              > Cameron Purdy
              > Tangosol Inc.
              > << Tangosol Server: How Weblogic applications are customized >>
              > << Download now from http://www.tangosol.com/download.jsp >>
              >
              >
              > "chand" <[email protected]> wrote in message
              > news:[email protected]...
              > > I am trying to create and send an XML file back to browser where XSL
              will
              > be
              > > applied. I am using wl6.0 sp2
              > >
              > > I tried like this
              > >
              > > <%@ page contentType="text/xml" %>
              > >
              > > <%
              > > out.println("<?xml version=\"1.0\"?>") ;
              > > out.println("<books>");
              > > out.println("<title>") ;
              > > out.println("XML Programming") ;
              > > out.println("</title>") ;
              > > out.println("</books>") ;
              > > %>
              > >
              > > But the browser is blank.
              > >
              > > Thanks
              > > shaikjava
              > >
              > >
              > >
              > >
              > >
              > >
              > >
              >
              >
              

  • Displaying data in xml using jsp

    how do we display data in database from jsp using xlst format in xml browser view

    how do we display data in database from jsp using xlst
    format in xml browser viewRefer this Post
    http://forum.java.sun.com/thread.jsp?forum=45&thread=482077&tstart=0&trange=15
    -Regards
    Manikantan

  • Print Specific Frames and Dynamic XML content

    Hello, I am trying to print specific frames of my Flash movie
    with the dynamic text loaded from an XML file. The code below only
    prints the current frame I am on and does not print the XML text.
    The dataOK that is commented out is a function I have before that
    loads the XML content. The XML content is loaded to dynamic text
    boxes. Any help on this would be greatly appreciated.

    I am still having difficulty loading the XML data and the
    frameNum parameter does not seem to work. Argghhhh....
    function printTut(myevent:MouseEvent):void{
    var myPrintJob:PrintJob = new PrintJob();
    var mySprite:Sprite = new Sprite();
    var printArea:Rectangle = null;
    var options:PrintJobOptions = null;
    var frameNum:int = 2;
    mySprite.addChild(stage);
    mySprite.rotation=90;
    mySprite.scaleY=.80;
    mySprite.scaleX=.80;
    myPrintJob.start();
    myPrintJob.addPage(mySprite,printArea,options,frameNum);
    myPrintJob.send();
    print_btn.addEventListener(MouseEvent.CLICK,printTut);

  • Make a dynamic menu using JSP or Javascript

    Hi ,
    I am trying to make a dynamic menu that is using data retrieved from database in the form of a list.
    I have a javascript to make a tree structure menu, but i need to iterate through the list i am reciveing from the database to make the tree structure. here is the code :-
    <Please reply ASAP as my deadline is near>
    <Note:- in javascript to make static menu ul tag is used to make the parent node and li tag is use to make the child node>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript" SRC="mktree.js"></SCRIPT>
    <LINK REL="stylesheet" HREF="mktree.css">
    </head>
    <body>
    <%@ page import = "java.util.ArrayList, java.util.Iterator, java.util.List, \WEB-INF\classes\DO_JSP.class,
    \WEB-INF\classes\Url_Name.class, java.util.Comparator, java.util.TreeSet, \WEB-INF\classes\MyComp.class" %>
    <%
         class Url_Name {
         String linkName;
         String linkUrl;
         int order;
         * @return the order
         public int getOrder() {
              return order;
         * @param order the order to set
         public void setOrder(int order) {
              this.order = order;
         * @return the linkName
         public String getLinkName() {
              return linkName;
         * @param linkName the linkName to set
         public void setLinkName(String linkName) {
              this.linkName = linkName;
         * @return the linkUrl
         public String getLinkUrl() {
              return linkUrl;
         * @param linkUrl the linkUrl to set
         public void setLinkUrl(String linkUrl) {
              this.linkUrl = linkUrl;
    class MyComp implements Comparator{
         public int compare(Object a, Object b){
              return (((Url_Name)a).getOrder() - ((Url_Name)b).getOrder());
         class DO_JSP
         int parentId;
         String parentName;
         TreeSet linkList;
         Url_Name tempurl;
         * @return the linkList
         DO_JSP(){
              linkList = new TreeSet(new MyComp());
         public TreeSet getLinkList() {
              return linkList;
         * @param linkList the linkList to set
         public void setLinkList(String linkName, String linkUrl, int order) {
              tempurl = new Url_Name();
              tempurl.setLinkName(linkName);
              tempurl.setLinkUrl(linkUrl);
              tempurl.setOrder(order);
              this.linkList.add(tempurl);
         * @return the parentName
         public String getParentName() {
              return parentName;
         * @param parentName the parentName to set
         public void setParentName(String parentName) {
              this.parentName = parentName;
         * @return the parentId
         public int getParentId() {
              return parentId;
         * @param parentId the parentId to set
         public void setParentId(int parentId) {
              this.parentId = parentId;
    %>
    <%
              List listdojsp =new ArrayList();
              listdojsp = (List)session.getAttribute("JspListName");
              Iterator it = listdojsp.iterator();
              do
    %>
              <%
              DO_JSP tempdojsp = (DO_JSP)it.next();
              String Parent = tempdojsp.getParentName();
              %>
              <ul class="mktree">     
              <li> Parent </li>
                   <ul>
              <%
              Iterator ittemp = tempdojsp.getLinkList().iterator();
                   do
                        Url_Name tempurlname = new Url_Name();
                        tempurlname = (Url_Name)ittemp.next();
                        String link = tempurlname.getLinkName();
              %>
                        <li>link</li>
              <%
                   }while(ittemp.hasNext());
              %>
                   </ul>
                   </ul>          
              <%     
              }while(it.hasNext());
              %>
    </body>
    </html>

    Hi ,
    I am trying to make a dynamic menu that is using data
    retrieved from database in the form of a list.
    I have a javascript to make a tree structure menu,
    but i need to iterate through the list i am reciveing
    from the database to make the tree structure. here is
    the code :- Hi, do you have a question? This is more of a "Look what I wrote" sort of post, and you don't seem to be asking for any specific advice. Please tell us what problem you're having, or the error message you're receiving.
    Brian

  • Generate XML using JSP

    I am trying to create and send an XML file back to browser where XSL will be
    applied. I am using wl6.0 sp2
    I tried like this
    <%@ page contentType="text/xml" %>
    <%
    out.println("<?xml version=\"1.0\"?>") ;
    out.println("<books>");
    out.println("<title>") ;
    out.println("XML Programming") ;
    out.println("</title>") ;
    out.println("</books>") ;
    %>
    But the browser is blank.
    Thanks
    shaikjava

    You haven't provided adequate relevant information. If you need help provide proper relevant details.

Maybe you are looking for

  • How do i see what firewire chipset I have?

    I want to know what kind of firewire chipset i have in my G5 (late 2004). I have a problem with my MOTU firewire interface but i cannot find the kind of firewire chipset i have inside my powermac. Tim

  • Help me with TabBars

    Hello Everybody Im begining the development of my new app, its a tab bar app for my friend band, the tab bar has 2 tabs (myspace and twitter). I followed this Xcode Tutorial http://www.youtube.com/watch?v=CNLIbrCl6Wo&hd=1 and I`ve done what it said ,

  • Hard drive or flash? Smart volume on Vision:M or new Z

    Hello all Hoping someone out there can answer one or both of my questions... Firstly, does anyone know if the new Zen or the Vision:M have the 'smart volume' function, which near-enough equalizes the volume of all music stored on the player Secondly,

  • Cost estimates

    Hi: All, Can any one Please explain the following with its applications 1) Standard Cost Estimate for material 2)Priliminary cost estimate for Product Cost COllector. please explain them with example. your help will be rewarded. Cheers, Nagesh.

  • Configuring a Certificate for ADFS on Server 2012 R2

    Preparing to install ADFS on Server 2012 R2 for SSO to applications outside of our organization.  For my needs, do I need two certificates? One for SSL and one for Claims? We have an internal Microsoft CA that I can get certs from. I have read that M