What are the mistake in this JSP program?

Hi,all. I am a newcomer to learn JSP, and I sincerely hope somebody help me. the following is a JSP program, and I want it extract data from my database and show them on webpage as XML. But there always have some mistakes I cann't found it. Could somebody help me find out them and tell me how to correct. Thanks veeeeeeeeeeeery much!
<%@ page contentType = "text/xml" %>
<%@ page language="java" %>
<%@ page import = "java.sql.* " %>
<%@ page import = "java.io.* " %>
<%@ page import = "javax.xml.parsers.DocumentBuilder" %>
<%@ page import = "javax.xml.parsers.DocumentBuilderFactory" %>
<%@ page import = "org.w3c.dom.Document" %>
<%@ page import = "org.w3c.dom.Element" %>
<%@ page import = "org.w3c.dom.Node" %>
<%@ page import = "org.w3c.dom.NodeList" %>
<%@ page extends = "Object"%>
<html>
<head><title>Searching Page</title></head>
<body>
<p><INPUT size=22 name=T1></p>
<p><INPUT type=submit value=OK name=B3></p>
<% Document retailerDoc = null;
Document dataDoc = null;
Document newDoc = null;
     try {
     DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
     DocumentBuilder docbuilder = dbfactory.newDocumentBuilder();
     retailerDoc = docbuilder.parse("RetailerXmlExtract.xml");
               //Instantiate a new Document object
               dataDoc = docbuilder.newDocument();
               //Instantiate the new Document
               newDoc = docbuilder.newDocument();
          }catch(Exception e){}
          //Retrieve the root element
          Element retailerRoot = retailerDoc.getDocumentElement();
          //Retrieve the (only) data element and cast it to Element
          Node dataNode = retailerRoot.getElementsByTagName("data").item(0);
          Element dataElement = (Element)dataNode;
          String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
          String connectURL = "jdbc:odbc:Retailer";
          Connection db = null;
          try{
               Class.forName(driverName);
               db = DriverManager.getConnection(connectURL);
               catch(ClassNotFoundException e){}
               catch(SQLException e){}
          //Create the PreparedStatement
          PreparedStatement statement = null;
          //Create the Resultset object, which ultimately holds the data retrieved
          ResultSet resultset = null;
          //Create the ResultSetMetaData object, which will holds
          //information about the ResultSet
          ResultSetMetaData resultmetadata = null;
          //Create a new element called "data"
          Element dataRoot = dataDoc.createElement("data");
          try{
               statement = db.prepareStatement("SELECT * FROM Orders");
               //Execute the query to populate the ResultSet
               resultset = statement.executeQuery();
               //Get the ResultSet information
               resultmetadata = resultset.getMetaData();
               //Determine the number of columns in the ResultSet
               int numCols = resultmetadata.getColumnCount();
               //Check for data by moving the cursor to the first record(if there is one)
               while(resultset.next()){
                    //For each row of data, create a new element called "row"
                    Element rowEl = dataDoc.createElement("row");
                    for(int i = 1; i <= numCols; i++){
                         //For each colum index, determine the column name
                         String colName = resultmetadata.getColumnName(i);
                         //Get the column value
                         String colVal = resultset.getString(i);
                         //Determine if the last column accessed was null
                         if(resultset.wasNull()){
                              colVal = "and up";
                         //Create a new element with the same name as the column
                         Element dataEl = dataDoc.createElement(colName);
                         //Add the data to the new element
                         dataEl.appendChild(dataDoc.createTextNode(colVal));
                         //Add the new element to the row
                         rowEl.appendChild(dataEl);
                    //Add the row to the root element
                    dataRoot.appendChild(rowEl);
          catch(SQLException e){}
          finally{
                    try{
                         db.close();
                         }catch(SQLException e){}
          //Add the root element to the document
          dataDoc.appendChild(dataRoot);
          //Retrieve the root element (also called "root")
          Element newRootInfo = (Element)retailerRoot.getElementsByTagName("root").item(0);
          //Retrieve the root and row information
          String newRootName = newRootInfo.getAttribute("name");
          String newRowName = newRootInfo.getAttribute("rowName");
          //Retrive information on element to be built in the new document
          NodeList newNodesRetailer = retailerRoot.getElementsByTagName("element");
          //Create the final root element with the name from the file
          Element newRootElement = newDoc.createElement(newRootName);
          //Retrieve all rows in the old document
          NodeList oldRows = dataRoot.getElementsByTagName("row");
          for(int i=0;i<oldRows.getLength();i++){
               //Retrieve each row in turn
               Element thisRow = (Element)oldRows.item(i);
               //Create the ner row
               Element newRow = newDoc.createElement(newRowName);
                    for(int j=0;j<newNodesRetailer.getLength();j++){
                         //For each mode in the new mapping, retrieve teh information
                         //First the new information........
                         Element thisElement = (Element)newNodesRetailer.item(j);
                         String newElementName = thisElement.getAttribute("name");
                         //Then the old information
                         Element oldElement = (Element)thisElement.getElementsByTagName("content").item(0);
                         String oldField = oldElement.getFirstChild().getNodeValue();
                         //Get the original values based on the mapping information
                         Element oldValueElement = (Element)thisRow.getElementsByTagName(oldField).item(0);
                         String oldValue = oldValueElement.getFirstChild().getNodeValue();
                         //Create the new element
                         Element newElement = newDoc.createElement(newElementName);
                         newElement.appendChild(newDoc.createTextNode(oldValue));
                         //Retrieve list of new elements
                         NodeList newAttributes = thisElement.getElementsByTagName("attribute");
                         for(int k = 0;k<newAttributes.getLength();k++){
                              //For each new attribute, get the order information
                              Element thisAttribute = (Element)newAttributes.item(k);
                              String oldAttributeField = thisAttribute.getFirstChild().getNodeValue();
                              String newAttributeName = thisAttribute.getAttribute("name");
                              //Get the original vale
                              oldValueElement = (Element)thisRow.getElementsByTagName(oldAttributeField).item(0);
                              String oldAttributeValue = oldValueElement.getFirstChild().getNodeValue();
                              //Create the new attribute
                              newElement.setAttribute(newAttributeName, oldAttributeValue);
                         //Add the new element to the new row
                         newRow.appendChild(newElement);
                    //Add the new row to the root
                    newRootElement.appendChild(newRow);
               //Add the new root to the document
               newDoc.appendChild(newRootElement);
          try{
               out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
               out.ptintln("<!DOCTYPE orders SYSTEM \"RetailerXml.dtd\">");
               out.println(newRootElement.toString());
          } catch(IOException e) {}
%>
</body>
</html>

it reminded that there were some mistakes when i run this JSP program,so it must have something wrong, but due to my weak programming skills, I can not found these mistakes out. That must give me very useful help if you tell me how to solve them. thank you vrey much!

Similar Messages

  • What are the events in Module Pool Programming ?

    hi,
    what are the events in Module Pool Programming ???
    thx

    Refer the following links :
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://help.sap.com/saphelp_webas630/helpdata/en/9f/db9cdc35c111d1829f0000e829fbfe/content.htm
    http://www.sap-img.com/
    http://help.sap.com/saphelp_46c/helpdata/en/08/bef2dadb5311d1ad10080009b0fb56/content.htm
    http://www.sapgenie.com/links/abap.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/c9/5472fc787f11d194c90000e8353423/frameset.htm
    http://www.sapdevelopment.co.uk/dialog/dialoghome.htm
    http://help.sap.com
    http://www.sapgenie.com/abap/example_code.htm
    http://help.sap.com/saphelp_47x200/helpdata/en/52/670ba2439b11d1896f0000e8322d00/frameset.htm
    http://www.allsaplinks.com/dialog_programming.html
    http://www.sapbrain.com/TUTORIALS/default.html
    http://www.sappoint.com/abap/spmp.pdf
    <b>Reward points if it helps in any way.</b>

  • What are the chances of this thing actually working?

    Hey there, over the next few sentences you'll probably be thinking I'm a hobo or something but whatever. I found an iPhone on the footpath today and it was kinda wet from inside. When I got it home and took it apart to see how much water was inside, there wasn't that much, a bit damp though. My dad dried it off with a blow dryer (Yeah I know, he isn't great with electronics) and cracked the screen right between the middle trying to open it up. I chargered it a little and I could faintly see the Apple logo. The screen went black shortly after and I couldn't do anything. Sometimes I can see something that looks like a USB plug but it was hard to tell. Any of the computers with iTunes in my house don't recognize the phone. The screen might turn into the Matrix's code (you know, all the green numbers lined up?) if you looked at it from real far and had sunglasses on.
    I think it's an Iphone 3G, so what are the chances of this thing actually working? Is it completely busted, would it be worth taking it to get repaired, selling it for spare parts or just throwing the thing away?

    It doesn't belong to you. Turn it in to the police.

  • What are the Technologies behind this mobile application ?

    What are the technologies involved in developing this mobile application?
    https://store.sap.com/sap/cpa/ui/resources/store/html/SolutionDetails.html?pid=0000004878&catID=MOB&pcntry=US&sap-langua…
    Is this Native/ Hybrid?
    based on MBO/Odata
    The graph is based on MAKIT / BI Mobile ?
    Looking at technical requirements it can be understood that the application is based on SUP , but how
    any other technologies involved which should be consider to develop a similar application?
    Note: The intention to know this is the curiosity to analyse mobile technologies only .

    Its difficult to guess the technologies have been used in developing this kind of apps.
    I guess this could be MBO based native app with MaKit. But at the same time i will suggest you to contact solution providers.
    Rgrds,
    Jitendra

  • What are the differences between this two statements???

    1.select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    2.select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    what are the differences between the 2 sql statements??
    I WILL APPRECIATE FOR YOUR ANSWERS VERY MUCH, BECAUSE I WAS PUZZLED WHEN I SAW THE EXECUTION PLANS.THANKS AGAIN. MR SHI.
    the followings are their execute plans:
    Command> select * from counter where eboxid = (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: IDX_SERVNUM
    INDEXED CONDITION: CM_SUBS_SUBSCRIBER.SERVNUMBER = qmark_1
    NOT INDEXED: ROWNUM < 3
    STEP: 2
    LEVEL: 2
    OPERATION: RowLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION:
    COUNTER.EBOXID = CM_SUBS_SUBSCRIBER.ACCTID
    NOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: NestedLoop
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: <NULL>
    Command> select b.* from zsyy_ocecs.CM_SUBS_SUBSCRIBER a,COUNTER b where a.acctid = b.eboxid and a.servnumber = ?;
    Query Optimizer Plan:
    STEP: 1
    LEVEL: 2
    OPERATION: TmpTtreeScan
    TBLNAME: ZSYY_OCECS.CM_SUBS_SUBSCRIBER
    IXNAME: <NULL>
    INDEXED CONDITION: <NULL>
    NOT INDEXED: A.SERVNUMBER = qmark_1
    STEP: 2
    LEVEL: 2
    OPERATION: TblLkTtreeScan
    TBLNAME: COUNTER
    IXNAME: IDX_COUNTER
    INDEXED CONDITION: B.EBOXID
    = A.ACCTIDNOT INDEXED: <NULL>
    STEP: 3
    LEVEL: 1
    OPERATION: MergeJoin
    TBLNAME: <NULL>
    IXNAME: <NULL>
    INDEXED CONDITION: A.ACCTID = B.EBOXID
    NOT INDEXED: <NULL>
    Edited by: user9533799 on 2008-9-3 上午1:28

    If zsyy_ocecs.cm_subs_subscriber table returns one row for each servnumber, both statements would return the same data. But if there was a servnumber value on two rows, the first statement will throw an error (you a comparing a value with a set of values). You can rewrite the first query to avoid this:
    select * from counter where eboxid in (select acctid from zsyy_ocecs.cm_subs_subscriber where servnumber = ?);
    Conceptually they are different and the execution plan can't be the same.

  • What are the 5 Most Useful Shareware programs you've come across?

    I wanted to lighten the mood on the forum with all of the complaints about the MBP with something potentially useful to current users as well as potential users like myself. I was just wondering what were the 5 most useful shareware programs people have come across for their MBP? It can range from security add ons, or networking tricks, really anything that saves you a few minutes of your day that you think sets your MBP apart from other MBPs and other portables in general.
    Oh, and please try not to include the macsaber....yes it was funny...the first 10 threads....

    1. Radio widget from WU: http://radiotuner.wuersch.net/
    you can just add any radion stream (url), they also have a list on their website (needs real player)
    2. Transmit (very user friendly FTP)
    3. Macjanitor (keeps the system tidy)
    4. VLC player (plays most media extensions)
    5. Skype (Phone any lan or mobile in the world from you mac/pc for a fraction of the cost, as well as normal chat)
    Actually i think most of that lot is freeware apart from Transmit; bargain!
    honorable mention for Appzapper, SuperDuper, google earth and firefox.
    hehe, mactheripper made me giggle - great name..

  • What are the main parts in ABAP Programing to work in Real Time ?

    Hi
    I would like to know hat are the main/important parts in ABAP Programing to work in real time environment.
    Moderator message : Search for available information. Thread locked.
    Edited by: Vinod Kumar on Aug 1, 2011 9:50 AM

    Hi Ashok,
    There are so many programming parts such as Function modules, report programs, workflows, smartforms, webdynpro, adobe forms, scripts etc.
    In which context you want answer can you please tell ?
    Regards,
    Aabha

  • Best practice implementation. What are the steps for this?.

    We had an upgrade from CRM 4 to 7 undertaken by some outfit (name deleted). After the upgrade was complete it would look as though the comapny carried on using the GUI interface rather than the WebUI interface, mainly because that's how CRM 4 worked. Now they would like to use the WebUI interface of CRM 7, as the GUI interface is no longer supported, but are receiving a number of errors when using certain features of teh WebUI. It would look as though a lot of config is missing, especially in the UI Framework area. I can only assume that whichever company performed the upgarde simply skipped this section when upgrading.
    I assume that I could download the best practice install/upgrade (?) and then just execute the section regarding the UI Framework, if such a section exists. bearing in mind that there seems to be a lot of config missing in the UI Framework section, would you recommend the course of action that I have mentioned?.
    Our WebUI Interaction centre is giving errors when we go in and I have been informed that I need to complete the config for:
    Customer Relationship Management->UI Framework->UI Framework Definition->Maintain Runtime Framework Profile
    But as I mentioned, there are lots of other sections in the UI Framework area that are empty and hence the suggestion I made above. Hopwever, I would specifically be interested to hear from anyone who can tell me what the entries are in the view table BSPWDV_RF_PROF_C and possibly the table BSPWDV_CTRL_REPL and BSPWDV_DEF_CC.
    I know this only completes part of the config, but it might be enough so that the WebUI IC can be viewed.
    On another subject, I have just come into this company and if I wanted to see what had been installed how do I go about that. for example, if I wanted to know if there had been an upgrade from 4 to 7 for a particular Industry solution, where do I check this?.
    Jason

    I have been through the following steps:
    Entered this URL http://help.sap.com/bp/initial/index.htm
    Clicked on 'Cross-industry Packages'
    Clicked on 'CRM'
    Clicked on 'Englilsh'
    Then the following page is displayed:
    http://help.sap.com/bp_crm70/CRM_DE/HTML/index.htm displayed
    But now what?. How do I get the Best practice instructions for a CRM implemenation?.
    Jason

  • What is the problem with this jsp

    <html>
    <head>
    <br>
    <br>
    <center>
    hi ,
    I have following jsp , it runs fine if i delete that if part, it prints the query string as null, i am getting errors becuse of that if , i am not undertsanding what is wrong with that part, someone please suggest.
    <h2>Enter the following data</h2>
    </center>
    <br>
    </head>
    <body bgcolor="#FFDAB9">
    <%
    String query = request.getQueryString();
    out.println("query is "+query);
    if(query.equals("null"))
    out.println("query is null");
    %>
    </body>
    </html>
    I ma getting folowing errors when i access it thorugh the browser
    java.lang.NullPointerException
         at org.apache.jsp.index_jsp._jspService(index_jsp.java:58)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)

    oh thanks it worked , i am doing this since yesterday.but why should i use == , i know equals compares the string and == compares the address ,here query string returns a string
    Anyway thank you once again

  • Custom tables create in Apps schema ( What are the problems with this?)wwww

    Hello all,
    I'm a dba in a new environment where a number of custom schemas are being created in the apps schema. I know this is not considered Oracle's best practice and I would like to make some recommendations for a change. Before doing so, I would like to know the problems that are associated with custom tables living in the apps schema. We are currently on 11.5.10.2 on AIX. Also, if someone can point me to any "Official" customization standard or Oracle documention where I can backup my case it would be greatly appreciated.
    Thanks in advance,

    Hi,
    Please see this thread.
    Custom application implemented in E-bussiness Suite
    Re: Custom application implemented in E-bussiness Suite
    Regards,
    Hussein

  • What are the elements of this pic?

    I am doing a lookbook for a friends clothing brand and this pic I found one the internet really caught my attention. I was wondering how I could make a normal pic look like this? Thanks!

    You would start out with a blank, new file, then add objects to it. It requires use of layers, gradients, type tool, etc.
    Are you experienced using Photoshop Elements?
    Can you photograph objects that you wish to incorporate in to your project?

  • What are the dememsions on this?

    thanks

    if you mean the 2nd gen ipod nano. and not the new phatty nano then the measurements is 3.5 inches by 1.5 inches. and 5 mm thick. Also this nano is an older model and not the newer one announced today.
    GFF

  • What are the external events in report programming

    hi
    experts
    pz help me for this qn

    Chk this.
    http://help.sap.com/saphelp_nw70/helpdata/en/9f/db9a0735c111d1829f0000e829fbfe/content.htm

  • What are the Minimum Number of Dia or BTC Work Process should be Configured

    Hi All,
    Can any One Let me Know why We need to Have 2 Minimum Dialog Work Process and not 1 or 3.
    What are the Task does this 2 Minimum work process handles in CI.
    Thanks & Regards
    Dan

    You need more than on if the system needs e. g. generate a program, this is done asynchronously, one process "waits" while a second generates a program. This is the absolute minimum, if you have only 1, you will stuck at the first time, the system needs to generate.
    Markus

  • I would like to activate open item management what is the impact of this

    HI,
    i would like to activate open item management what is the impact of this  FAGL_ACTIVATE_OP program 
    i am not under standing why this many entries are happening for this i have tested in DEvelopment
    40 SERVICE TAX-SHE CESS-RECEIVABLE-INPUT SERVICES
    50 50000029   MEDICAL REIMBURSEMENT  (Original entry)
    system posted documents
    2nd entry
           50  27051306         SERVICE TAX-SHE CESS-RECEIVABLE-INPUT SERVICES
           40  99900001GL Offset Account
    (TExtTransfer Posting: Activation of Open Item Manageme)
    3rd entry
    40         27051306   SERVICE TAX-SHE CESS-RECEIVABLE-INPUT SERVICES
    50         27051306   SERVICE TAX-SHE CESS-RECEIVABLE-INPUT SERVICES
    (TextTransfer Posting: Zero Balance per Acct Assignment)
    4th entry
    document no was happend
    Clearing document with out Lint items
    5th entry it is ok it is new open balance
    40 27051306   SERVICE TAX-SHE CESS-RECEIVABLE-INPUT SERVICES
    50  99900001   GL Offset Account
    (TExt   Reposting for Open Item Activation)
    can any body give some explanation
    Regards,
    madhav

    You would have to purchase a second subscription since one subscription allows for only two active installations of which only one can be in use at a time.
    As far as cost goes...
    Creative Cloud Plans
    https://creative.adobe.com/plans

Maybe you are looking for

  • Safari warning before quitting when multiple tabs are open?

    I'm a rather clumsy typist who often uses Apple+Tab to toggle through my open programs. This works great 99% of the time, but that other 1% is rather frustrating considering that the Q key is right next to Tab. Apple guys, please implement a pop up/d

  • FTP Adapter batching multiple files in one send

    Hello, I'd like to set up a process in XI to allow me to group all files into one batch message and send the group all in one send every thirty minutes.  This is an FTP adapter. Do I need to work through a BPM to do this?  Is there a good blog or for

  • How do I download os6 to my 1st generation iPad

    My first generation iPad will not download OS6, is there any way to do it?

  • ORA-01000: maximum open cursors exceeded with Thin and OCI

    Hi I have this ERROR : ORA-01000: maximum open cursors exceeded ORA-06510: PL/SQL: unhandled user-defined exception ORA-06512: at line 1 and all the connections show this error, I run the weblogic.Admin RESET_POOL utility and the problem are fixed !!

  • OSX 10.6.6 not reading hosts file

    I am moving a website to another server, but I don't want any down time while I build it. I have transferred the domain name to my new server, but the DNS still points to the old location. I have edited the /private/etc/hosts file in terminal to refl