Get xml data to jsp

I have a XML generated webpage (a jsp). I want to read this data from another jsp or java class.
How is this done in the best way.
I thought first to do this:
URL url = new URL("webpage adress);
url.getContent(); // Here I thought that the XML data will be put.{code}
But this doesn't work
Can anyone show me a better example?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

http://java.sun.com/docs/books/tutorial/networking/index.html
Particularly "Working with URLs".

Similar Messages

  • How get xml-data at servlet by http and parse it?

    hello! please help me who can, i have very urgent task but not much skilful to deal with work in web. is anywhere source code or similar example of task to get xml-data at servlet by http and parse it . thank you in advance

    here a basic code that reads and parses an remote xml file:
    import java.io.IOException;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import javax.xml.parsers.SAXParserFactory;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    public class SAXParserExample extends DefaultHandler {
         StringBuffer buffer;
         String urlString = "http://nds.nokia.com/uaprof/NN95_8GB-1r100.xml";
         public SAXParserExample() {
         public void runExample() {
              parseDocument();
         private void parseDocument() {
              // get a factory
              SAXParserFactory spf = SAXParserFactory.newInstance();
              try {
                   // get a new instance of parser
                   SAXParser sp = spf.newSAXParser();
                   URL url = new URL(urlString);
                   HttpURLConnection httpSource = (HttpURLConnection) url.openConnection();
                   // parse the file and also register this class for call backs
                   sp.parse(httpSource.getInputStream(), this);
              } catch (SAXException se) {
                   se.printStackTrace();
              } catch (ParserConfigurationException pce) {
                   pce.printStackTrace();
              } catch (IOException ie) {
                   ie.printStackTrace();
         // Event Handlers
         public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
              System.out.println("+++ start of element: " + qName);
              buffer = new StringBuffer();
         public void characters(char[] ch, int start, int length) throws SAXException {
              buffer.append(ch, start, length);
         public void endElement(String uri, String localName, String qName) throws SAXException {
              System.out.println(buffer.toString());
              System.out.println("+++ end of element " + qName);
         public static void main(String[] args) {
              SAXParserExample spe = new SAXParserExample();
              spe.runExample();
    }you have only to change the urlString and adapt to your needs.
    hope it helps

  • Get XML data into SAP

    Hi ,
    Is there any function module to get XML data into SAP?
    If function module doesnt exist, suggest alternative to do it.
    Thanks,
    Shivaa...

    Hi Shiva ,
    there is lot of stuff regarding ur query in SDN....
    anyways check this link...
    https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/upload%252bxml%252bfile%252bto%252binternal%252btable
    hope this solves ur problem.
    Regards,
    Anuj

  • How can we store xml data using jsp

    hai,
    Can anyone please explain in brief how to store xml data using jsp. Also if possible please explain by specifying the code.
    regards,
    Praveen Vinnakota.

    [email protected] wrote:
    how can we publish Labview data using the web?
    You could use shared variables and publish them to the network or use data sockets.
    Kudos always welcome for helpful posts

  • Problem Using HTTP Dispatcher -- Could Not able to get the data in JSP

    Hi, I am using HTTP Dispatcher to send my events to particular URL which is a JSP page. I am trying to populate the received event through URL and populate to a oracle data base. But could not able to get the data in Oracle database.
    Code is :
    <h1>JSP Page</h1>
    <%
    long type = 0;
    String tagId = null;
    String timeStr = "0";
    String deviceName = "";
    // Get Event Parameters
    // Available Parameters: id, siteName, deviceName, data, time, type, subtype, sourceName, correlationId
    try
    type = Long.parseLong(request.getParameter("type")); // Get type
    tagId = request.getParameter("id"); // Get tagId
    timeStr = request.getParameter("time"); // Get time
              deviceName = request.getParameter("deviceName");
    catch (Exception e)
    out.println( "Error: "+e.getMessage() );
              // Write into DB.
              try {
              if ((tagId == null) || (type != 200) ){
                   // Do Nothing
                   //return;
              } else {
                   OracleDataSource ods = new OracleDataSource();
                   String URL = "jdbc:oracle:thin:@//3.235.173.16:1525/vislocal";     
                   ods.setURL(URL);
                   ods.setUser("cus");
                   ods.setPassword("cus");
                   Connection myConn = ods.getConnection();     
                   Statement stmt = myConn.createStatement();
                   String selectQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads ";
                   ResultSet rs = stmt.executeQuery(selectQuery);
                   String maxId = "1";
                   if (rs.next()) {
                        maxId = rs.getString(1);               
                   String selectMaxTagIDQuery =
                             "SELECT MAX(rfid_raw_reads_id) as max_id FROM "+
                        "cus.rfid_raw_reads WHERE tag_id = '" + tagId + "'" ;
                   stmt = myConn.createStatement();
                   rs = stmt.executeQuery(selectMaxTagIDQuery);
                   String maxTagId = "1";
                   if (rs.next()) {
                        maxTagId = rs.getString(1);               
                   long primaryKey = 1;
                   long tagKey = 1;
                   try {
                        primaryKey = Long.parseLong(maxId) + 1;
                        tagKey = Long.parseLong(maxTagId) + 1;
                   } catch (Exception e) {
                   long currentTime = System.currentTimeMillis();
                   long updateKey = (tagKey - 1);
                   String updateQuery = " UPDATE cus.rfid_raw_reads SET read_end_time = " + currentTime + " WHERE rfid_raw_reads_id = " + updateKey;
                   Statement updateStmt = myConn.createStatement();
                   updateStmt.execute(updateQuery);     
                   String query =
                        "INSERT INTO cus.rfid_raw_reads (rfid_raw_reads_id, tag_id,device_name,read_start_time) VALUES ("+ primaryKey + ",'" + tagId + "'," + deviceName + "'," + System.currentTimeMillis() + " )" ;
                   Statement insertStmt = myConn.createStatement();
                   insertStmt.execute(query);     
                   myConn.commit();
                   myConn.close();
              } catch (Exception e) {
    %>
    <p>For browser debug:
    <%
    out.println( "Type="+type+" ID="+tagId +" time="+timeStr );
    %>
    Kindly suggest where is the problem...
    Thanks and regards
    Mohammad Nasim Akhtar

    HI Prabhat,
    Thanx for your reply, I worked out and able to receive the data in oracle database, Actually there was some problem in insert Query. Now I have tested the same... and able to edit the same in the Database.....
    But I am facing a new problem, Http Dispatcher in SES console is displaying all the Events generated as well as event in Que but there is no events in the Event Send. I guess it is not able to send the events.....?????
    Event statical is showing like this
    Events Received: 0 (0.00/sec)
    Events Generated: 311 (0.19/sec)
    Events Sent: 2 (0.19/sec)
    Queued Events: 309 (0.19/sec)
    Kindly suggest where is the problem, Is it a JSP problem or OSES end problem.....
    Thanks and regards
    Nasim

  • Get xml data from a web service into Forms?

    Hello folks! I am reading active directory info from a web service into forms via imported java classes. I can read from functions that return strings just fine, but I have to get the output from getGroupUsers which returns an XmlDataDocument. How do I read this in and parse it in Forms?
    I will be grateful if y'all could point me to an example.
    Thank you,
    Gary
    P.S. Here is a snippet of how I get the full name by passing an ID:
    DECLARE
    jo ora_java.jobject;
    rv varchar2(100);
    BEGIN
    jo := ADSoapClient.new;
    rv := ADSoapClient.getUserName(jo, 'user_ID');
    :block3.fullname := rv;

    Hello,
    Since you are already dealing with server-side JAVA, I would suggest you create a method that would do the parsing server-side and what your PL/SQL will be dealing with is just the return string.
    Here is a method I use to read an XML file (actually, it is an Oracle Reports file converted to XML) and from the string version, I will do search, replace and other things.
    So, from getGroupUsers which returns an XmlDataDocument, you can adapt this method to get your data server-side and let the form module read the output data.
    <blockquote>
    private String processFileXml(String fileName, int iFile) throws ParserConfigurationException, SAXException,
    IOException, XPathExpressionException{
    try{                
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    domFactory.setNamespaceAware(true);
    InputStream inputStream = new FileInputStream(new File(fileName));
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document doc = builder.parse(inputStream);
    StringWriter stw = new StringWriter();
    Transformer serializer = TransformerFactory.newInstance().newTransformer();
    serializer.transform(new DOMSource(doc), new StreamResult(stw));
    return stw.toString();
    catch (Exception e){
    System.err.println(e);
    System.exit(0);
    return "OK";
    </blockquote>
    Let me know if this is of nay help.
    Thanks.

  • Getting XML data of SSIS Package (which is located in File System) from a query

    Hi,
    We have around 200 SSIS packages deployed to File System. These pacakges are being scheduled using SQL Agent job.
    So, currently I have a list of all the packages and their respective File Path.
    Note : **They are NOT deployed to Server**.
    Now, my task is to search all the packages which has a specific connection in it.
    From the below blog, I got to know we can achieve this by querying the XML data of the SSIS Package.
    https://www.simple-talk.com/sql/ssis/-exploring-ssis-architecture-and-execution-history-through-scripting/.
    But in the above article they are getting the XML definition of the Package from msdb(as it was deployed to server).
    In my requirement, SSIS Packages are in File System. Is there any way to to get the XML definition of these packages using a query.
    Please let me know if the above requirement is not clear or if any further information is required.
    Thanks
    Raksha

    Hi Visakh & Praveen,
    Thanks for the response. 
    @Visakh: The query provided by you gives the information about all the connection strings in the package.
    @Praveen: The query in the link provided by you lists the values of all the properties of the package like MaxerrorCount, CreatorName, CreatorDate and other properties.
    I think, we may have to slightly modify this query to get the connection string values
    Praveen, nice to hear from you after a long time and that too in this forum !! :) Hope you are doing good.
    Thanks
    Raksha

  • How do I initialize an array after getting xml data via httpservice?

    I am having a problem trying to initialize an array with data from an external xml file obtained via httpservice.  Any help/direction would be much appreciated.  I am using Flex 4 (Flash Builder 4).
    Here is my xml file (partial):
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Root>
        <Row>
            <icdcodedanddesc>00 PROCEDURES AND INTERVENT</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.0 THERAPEUTIC ULTRASOUND</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.01 THERAPEUTIC US VESSELS H</icdcodedanddesc>
        </Row>
        <Row>
            <icdcodedanddesc>00.02 THERAPEUTIC ULTRASOUND O</icdcodedanddesc>
        </Row>
    </Root>
    Here is my http service call:
    <s:HTTPService id="icdcodeservice" url="ICD9V2MergeNumAndDescNotAllCodes.xml"
                           result="icdcodesService_resultHandler(event)" showBusyCursor="true"  />
    (I have tried resultFormat using object, array, xml).
    I am using this following Tour de Flex example as the base -http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500
    and updating it with the httpservice call and result handler.  But I cannot get the data to appear - I get [object Object] instead.  In my result handler code  I use "icdcodesar = new Array(event.result.Root.Row);"  and then "icdcodesar.refresh();".
    The key question is: How to I get data from an external xml file into an array without getting [object Object] when referencing the array entries.  Thanks much!
    (Tour de Flex example at http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#docIndex=0;illustIndex=1;sampleId =70500  follows)
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:local="*"
                   skinClass="TDFGradientBackgroundSkin"
                   viewSourceURL="srcview/index.html">
        <fx:Style>
            @namespace s "library://ns.adobe.com/flex/spark";
            @namespace mx "library://ns.adobe.com/flex/mx";
            @namespace local "*";
            s|Label {
                color: #000000;
        </fx:Style>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                private var names:ArrayCollection = new ArrayCollection(
                    ["John Smith", "Jane Doe", "Paul Dupont", "Liz Jones", "Marie Taylor"]);
                private function searchName(item:Object):Boolean
                    return item.toLowerCase().search(searchBox.text) != -1;
                private function textChangeHandler():void
                    names.filterFunction = searchName;
                    names.refresh();
                    searchBox.dataProvider = names;
                private function itemSelectedHandler(event:SearchBoxEvent):void
                    fullName.text = event.item as String;   
            ]]>
        </fx:Script>
        <s:layout>
            <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" />
        </s:layout>
        <s:Panel title="Components Samples"
                 width="600" height="100%"
                 color="0x000000"
                 borderAlpha="0.15">
            <s:layout>
                <s:HorizontalLayout horizontalAlign="center"
                                    paddingLeft="10" paddingRight="10"
                                    paddingTop="10" paddingBottom="10"/>
            </s:layout>
            <s:HGroup >
                <s:Label text="Type a few characters to search:" />
                <local:SearchBox id="searchBox" textChange="textChangeHandler()" itemSelected="itemSelectedHandler(event)"/>
            </s:HGroup>
            <mx:FormItem label="You selected:" >
                <s:TextInput id="fullName"/>
            </mx:FormItem>
        </s:Panel>
    </s:Application>

    Hello,
    Instead of extracting the first zero element from the vid array, you should take that out and connect it allone.
    Attachments:
    init.bmp ‏339 KB

  • How can I get xml data from KM?

    Hi guys,
    how can i get a xml data from KM?
    I saved an xml document in KM, and I want to read its content. How can I get this document?
    Using
    DocResource = (IResource) resFactory.getResource(RID.getRID("Document/ Path"),resContext)?
    I want to know which kinds of API of KM are responsible for this.
    Thanks in advance
    Regards,
    Liying

    Hi Liying
    use this code.
    try {
                   IWDClientUser wdClientUser = WDClientUser.getCurrentUser();
                   IUser sapUser = wdClientUser.getSAPUser();
                   com.sapportals.portal.security.usermanagement.IUser ep5User =
                        WPUMFactory.getUserFactory().getEP5User(sapUser);
                   IResourceContext resourseContext = new ResourceContext(ep5User);
                   IResourceFactory resourseFactory = ResourceFactory.getInstance();
                   RID pathRID =
                        RID.getRID(
                             "/documents/"(Path to folder where ur file is"");
                   ICollection collection =
                        (ICollection) resourseFactory.getResource(
                             pathRID,
                             resourseContext);
                   IResourceList resourceList = collection.getChildren();
                   IResourceListIterator resourceListIterator =
                        resourceList.listIterator();
    while (resourceListIterator.hasNext()) {
                        com.sapportals.wcm.repository.IResource resource =
                             resourceListIterator.next();
    try {
                             /*File from KM Reading*/
                             InputStream in = resource.getUnfilteredContent().getInputStream();
                             ByteArrayOutputStream out = new ByteArrayOutputStream();
                             byte[] buffer = new byte[4096];
                             int bytesread = 0;
                             while ((bytesread = in.read(buffer)) != -1) {
                                  out.write(buffer, 0, bytesread);
                             String dataToBeConvertedToXML = out.toString();
    catch(Exception e){}
    catch(Exception e){}
    Award points if found usefull.
    I suppose you have used KM sharing reference in ur application
    Regards
    BP

  • Read/get xml data (string)

    Hi
    I have a XML string that I get from a TCP transfer, I have attached a received string.
    I have no experience in reading XML data, I have tried looking in the forums and some of the examples in LV, but I cannot get it to work, so I hope that someone could help me out. All I need to get from the XML data are the names e.g. Station1 and Station2 perhaps putted into a string array. If so it wouldn't hurt to get all the rest parameters and attributes as well. I thought about doing some string searches to get what I need, but thought again that it might be easier/better in some way to take advantage of the data being arranged as XML.
    Hope that someone can help.
    Thanks in advance
    Best regards
    Simon
    LabVIEW 8.6 / 2009 / 2010
    Vision Development Module 8.6 / 2009 / 2010
    VBAI 3.6 / 2010
    Attachments:
    testmap.txt ‏1 KB

    Hi all
    falkpl wrote:
    The easy way is if you know that this string is not changing much you treat it as a formated string and parse it using simple string functuions
    ie first parse %s and %s The two slashes will cancle the escape clause of the string parser.  Repete this process to get each station and attributes.
    The harder way is to use an activeX or .net XML parser.
    Paul
    I am not sure what you mean about the parser, well I get the concept, but is there a specific string function that can do that for me?
    I got something working with the Match Pattern vi, please the attached. This actually works for my current needs, but I still would be able to get data from more complex XML data.
    Hi A.K. and J.K.
    Thank you for the link.
    EasyXML looks like a nice and handy tool for handling XML data. I ran in too some problems though when running the VI Package Manger. When I check the network for new packages it says that there was an error, please check the network connection or settings. I have internet connection (I am writing this post ) and I am not using a proxy server. What could be wrong and how do I install EasyXML then, is there another way?
    Best regards
    Simon
    LabVIEW 8.6 / 2009 / 2010
    Vision Development Module 8.6 / 2009 / 2010
    VBAI 3.6 / 2010
    Attachments:
    my_get_xml_data.vi ‏15 KB

  • Getting XML Data

    I create a Data Model and Save it When i click on Get XML output the data it shows a blank page XML data is not displayed and later when i try to create a Report based on existing DM it gives a message...NO Sample data is saved for the existing DM.... Can anyone help?

    From 11g
    When you created data model and view xml you gave drow down option on the right top saying
    Export xml
    Save as sample data
    Get data engine log.
    Once you completed creating daramodel and view xml please click that option save as sample data . The xml which you viewed will be saved as sample xml file for that data model.
    It is must if you want ti upload a template to created data model.
    It is a one time job that we need to do whenever we create a new datamodel.
    for reference u can check the below link.
    Viewing the XML Output and Saving the Sample Data
    1 You may have observed that In the current version of the BI Publisher, you can preview the XML data for the data model.
    Click the XML icon (found at the right top corner of the page), to see the XML output for the data model you defined in previous topic.
    Select All for the number of rows, and click Run to see the XML data output for all the departments:
    ( A portion of the XML data is displayed here in the screen)
    2 .To save this as sample data, click the Open Menu drop-down list icon, and select Save as Sample Data.
    You can see that the sample.xml is listed in the Sample Data section of the Data Model ( as shown below):
    Note: It is very important to save sample data for a data model, else when creating Layouts, the previews do not appear correctly.
    http://st-curriculum.oracle.com/obe/fmw/bi/bip/bip11g/gettingstarted/gettingstarted.htm
    Assign me some points if helpful.

  • What is the best and easiest way to get xml data into the rtf document

    Hello Frenz
    I'm using rtf document(with bi publisher desktop plug in installed in the word document)... please suggest me the best way(to get the xml data from tables) to load the xml data into this rtf document..
    I'm not developing oracle apps reports. It is for Oracle retail...
    another doubt is... in the rtf document itself there is oracle bi publisher.. can it be used for generating xml data...
    please bear with me and suggest me a way out
    Thanks and regards

    What will you be using in your production system to generate XML? Or are you just trying out BIP?
    If you're familiar with dbms_xmlquery.getxml , you can pass your SQL to generate the XML output. Save the output in a file and use it in your RTF template.
    If you have Oracle reports, you can create XML output when you run the report.

  • XML data in JSP file

    Guys,
    I need to output some XML data inside my jsp program. This is simple contact xml file, and I need to output that data to the screen.
    Can someone show me code example or point me where I can find one.
    Thanks

    http://developer.java.sun.com/developer/technicalArticles/xml/WebAppDev2/

  • Getting xml data into Oracle 9.2

    Hi
    URGENT! NEED HELP ASAP PLEASE!
    I have an unique situation.
    Iam getting large data in XML wrapper.The XML file has all sort of data in it
    1. Multi-delimited text data in CData section
    e.x H3005234 John Koenig 123 Street
    H4004567 99999999 $1000.00 $200.00
    2. Formatted text data in CData section which I need to preserve
    I need to Take each of this data section and write it to individual normalized database columns
    Iam thinking of taking the following approach
    Use XMLDB and PL/SQL to parse the data and do data transofrmations
    Iam having the following problems
    1. The Multi-delimited data in CData section when i create a .xsd file is treated as text.Iam worried that since this is a multi-delimited fixed width file having white spaces .will the white spaces be eliminated while storage if so how would i parse the data to know which data belwongs to what section or record
    2. How do i register the schema so that i can use the best approach to solve the issues
    Please help
    Thankyou
    Seshadri
    [email protected]
    thx

    >
    Oracle version: 8i - 9.0.x.x
    There was no option that I can recall or could find. All the parsing of XML that I've done in 8i was via the xmldom package.
    Oracle version: 9.2.x.x - 10.1.x.x
    This is were Oracle introduced extract, extractValue and TABLE(XMLSequence(extract())) for dealing with repeating nodes.
    Oracle version: 10.2.x.x
    Oracle introduced XMLTable as a replacement for the previous methods since it could handle all three methods for extracting data from XML. At that point, Oracle stopped enhancing extract/extractValue in terms of performance and focused on XMLTable. In 10.2.0.1 and .2, XMLTable was implemented via Java and in .3 it was moved into the kernel so performance from .3 onwards should be better than the older 9.2 / 10.1 methods. If not, feel free to open a ticket with Oracle support. Apparently Oracle also introduced XMLQuery as well but I've never heard of many using that in 10.2
    >
    from Methods to parse XML per Oracle version
    so use correct way for your oracle version

  • How to get XML data of IDOC

    Hello ABAP gurus
    I am an SAP PI consultant working on some IDOCs.
    I am able to see the payload (in XML format)  sent via IDOC adapter.
    This is being sent to our backend system (ECC 6.0). I would like to know if there is any way that I can see this IDOC in XML format  on the ECC side so that I can compare it with the XML data that I see on PI side.
    After checking old postings on SDN, I have tried tables like EDIDC, EDISYN and EDID4. I even tried IDOC transactions like WE02, WE60 etc.,  But couldn't see the XML data.
    Any suggestions or comments will be highly appreciated.
    Thanks
    Ram

    Hi
    Check SXMB_MONI in ECC if you find the message. I am not sure but you can have a look.
    Regards
    Vinit

Maybe you are looking for