Solved

I cannot display the tags of the XML file in my browser

Posted on 2004-10-28
157 Views
Last Modified: 2013-11-19
I have a .jsp page which display the content of the file( it may be text of the XML).My probelm is, when I try to display the XML file, it displays only the content of the XML file with out the tags.Could you please help me with this issue.Thanks a lot


 
0
Question by:g46905
    20 Comments
     
    LVL 13

    Expert Comment

    by:petmagdy
    the jsp should be like this:

    /////////////////////////////////////////////////////

    <%@ page contentType="text/xml; charset=windows-1252"%>
    ....
        <name>Peter</name>
    ......


    //////////////////////////////////////////////////
    page type should be text/xml
    0
     

    Author Comment

    by:g46905
    This is what I currently have for my .jsp page.

    <link rel="stylesheet" type="text/css" href="cs1.css" />

    If I change it to the above mentioned ( ie <%@ page contentType="text/xml; charset=windows-1252"%> ).Will it not affect my css style sheet. I do not have lot of experience with webpage dev.Could you please help me with your valuable suggestion?

    Thanks
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    I am toking about ur ( <%@page ) attribute not about the <link,

    if u have already <%@page please overwrite it

    if not add the line I sugggested at the begining of ur jsp
    0
     

    Author Comment

    by:g46905
    This is what I have at the begining of the .jsp file

    <%@ page import="com.midamerican.edi.webview.DoView" %>
    <%@ page import="java.util.Vector" %>

    Do you want me to add it after this?

    Thanks,



    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    yes please add
    0
     

    Author Comment

    by:g46905
    This is what received when I tried to view the xml file.Could you please tell me where I am going wrong?

    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


    --------------------------------------------------------------------------------

    A name contained an invalid character. Error processing resource 'http://localhost:9080/edi/View.jsp?id=175846&name=175846_175841_mida8338_OUT867Usage_20041101021248.zip&chkview=1'. Line 44, Position 9

    <Message&nbsp;xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'&nbsp;xsi:noNamespaceSchemaLocation='http://www.suppliers.detroitedison.com/internet/xmlschemas/OUT867Usage_v4_01.xsd'><Header><Type>OUT867Usage</Type><MessageId>53604</MessageId><Usage>Production</Usage><Date><DateTime>2004-11-01T02:12:47.290-05:00</DateTime><TimeZone>ET</TimeZone></Date><ConsumerServiceProvider>Detroit&nbsp;Edison</ConsumerServiceProvider><SupplierDUNS>963008388</SupplierDUNS></Header><Transaction><TransactionId>592496</TransactionId><CustomerName>AUTOZONE&nbsp;INC</CustomerName><AccountNumber>16580280014</AccountNumber><BillingType>Separate</BillingType><InvoiceNumber>165802800140003002</InvoiceNumber><InvoiceDate>2004-10-27</InvoiceDate><InvoiceStartDate>2004-09-23</InvoiceStartDate><InvoiceEndDate>2004-10-21</InvoiceEndDate><IntervalMeters><IntervalMeterSummary><MeterNumber>5356351</MeterNumber><Sink>MECR</Sink><BeginningReadDate>2004-09-23</BeginningReadDate><EndReadDate>2004-10-21</EndReadDate><MeterConfiguration><NumberOfDials>5</NumberOfDials><Qualifier>TimeOfUse</Qualifier><MeterInterval>30</MeterInterval></MeterConfiguration><Quantity><BeginningReading>216.0</BeginningReading><BeginningReadType>Actual</BeginningReadType><EndReading>283.0</EndReading><EndReadType>Actual</EndReadType><MeterMultiplier>160</MeterMultiplier><Consumption>10720.0</Consumption><UnitOfMeasure>KWH</UnitOfMeasure></Quantity><OnPeakEnergyUsage><Value>6449.0</Value><UnitOfMeasure>KWH</UnitOfMeasure></OnPeakEnergyUsage><OffPeakEnergyUsage><Value>4271.0</Value><UnitOfMeasure>KWH</UnitOfMeasure></OffPeakEnergyUsage><MonthlyHighestDemand><Value>40.0</Value><UnitOfMeasure>KW</UnitOfMeasure><ReadDate><DateTime>2004-09-23T20:00:00.000-05:00</DateTime><TimeZone>ET</TimeZone></ReadDate></MonthlyHighestDemand><MonthlyOnPeakDemand><Value>40.0</Value><UnitOfMeasure>KW</UnitOfMeasure><ReadDate><DateTime>2004-09-23T20:00:00.000-05:00</DateTime><TimeZone>ET</TimeZone></ReadDate></MonthlyOnPeakDemand><TwelveMonthMaxBillingDemand><Value>47.0</Value><UnitOfMeasure>KW</UnitOfMeasure><ReadDate><DateTime>2004-08-02T19:30:00.000-05:00</DateTime><TimeZone>ET</TimeZone></ReadDate></TwelveMonthMaxBillingDemand><PowerFactor>0.9363</PowerFactor></IntervalMeterSummary><IntervalMeterDetail><UOM>KWH</UOM><TimeZone>ET</TimeZone><DailyIntervals><DetailDate>2004-09-23</DetailDate><Values><DetailTime>0030</DetailTime><Value>4.7</Value></Values><Values><DetailTime>0100</DetailTime><Value>4.9</Value></Values><Values><DetailTime>0130</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0200</DetailTime><Value>4.42</Value></Values><Values><DetailTime>0230</DetailTime><Value>4.61</Value></Values><Values><DetailTime>0300</DetailTime><Value>4.8</Value></Values><Values><DetailTime>0330</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0400</DetailTime><Value>4.42</Value></Values><Values><DetailTime>0430</DetailTime><Value>4.61</Value></Values><Values><DetailTime>0500</DetailTime><Value>4.7</Value></Values><Values><DetailTime>0530</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0600</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0630</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0700</DetailTime><Value>4.8</Value></Values><Values><DetailTime>0730</DetailTime><Value>4.51</Value></Values><Values><DetailTime>0800</DetailTime><Value>7.1</Value></Values><Values><DetailTime>0830</DetailTime><Value>8.83</Value></Values><Values><DetailTime>0900</DetailTime><Value>8.93</Value></Values><Values><DetailTime>0930</DetailTime><Value>8.64</Value></Values><Values><DetailTime>1000</DetailTime><Value>8.54</Value></Values><Values><DetailTime>1030</DetailTime><Value>8.64</Value></Values><Values><DetailTime>1100</Deta
    --------^


    Thanks
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    apparantly a tag is not closed probably at line 44 position 9
    0
     

    Author Comment

    by:g46905
    My file doesnt contain so many lines.I wonder why it specifies line 44? Could you please help me?

    Thanks
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    please post the complete jsp code
    0
     

    Author Comment

    by:g46905
    I am posting the code.Please let me know if you cannot follow anything.



    <%--
              Author: venu g singavarapu      
              Last Modified : 12/27/02        
            Author: Chandra Shekar Gokaraju  
            Last modified : 03/12/04        
       
    --%>


    <%@ page import="com.midamerican.edi.webview.DoView" %>
    <%@ page import="java.util.Vector" %>


    <jsp:useBean id="dv" class="com.midamerican.edi.webview.DoView" scope="page" />

    <%!

        Object op = null;
        Vector v = null;
        String str = null;
        String main;
        String name = "";
        String id = "";
        String chkview = "";
        String lin = "";
        String pwd = "";

    %>


    <html>
    <head>

    <link rel="stylesheet" type="text/css" href="cs1.css" />


    <title>V I E W .....</title>


    <script language="JavaScript">

    function winClose()
    {
       
       window.close();
       return false;
    }

    </script>
    </head>

    <body >

    <center>
    <br><br>
    <table  align="Center" width="1800">

    <tr><td>

    <%

            //System.out.println(request.getParameter("id"));// debug
            //System.out.println(request.getParameter("name")); // debug

            name = request.getParameter("name");
            id = request.getParameter("id");
            chkview = request.getParameter("chkview");
            lin = (String) session.getValue("slogin");
               pwd = (String) session.getValue("spassword");
         
           if (chkview.equals("1")) {
         
           op = dv.showFile(name,lin,pwd,chkview);  // calling the show file method for before translation      
         
            }
           
           if (chkview.equals("2")) {
                 
            op = dv.showFile(name,lin,pwd,chkview); // calling the show file method for after translation
             
             }
                   
            if (op instanceof Vector)
             {
            
              v = (Vector) op;
             // out.println(" Printing line by line");
             main = v.get(0).toString();
             String main2 = main;
             String sub1="";
             boolean standardEOL =false;
             int noflines = 0;

             for (int j=0; j< main.length(); j++)
                {
                    if(main.charAt(j) == '\n')              
                       {
                           noflines = noflines + 1;
                           standardEOL = true;
                       }
                 }
              //  out.println("noflines=" + noflines);  

            for (int i=0; i<noflines; i++)
            {
             sub1 = main.substring(0,main.indexOf("\n"));
             out.println(sub1);
               main = main.substring(sub1.length()+1);
     
            %>

             <br>  

         <%
           
           
             }  // for  

         if (!standardEOL){
                if(main.length() > 0){
                   out.println(main);
                }
            }  

                   
    } // if  instance of vector


    %>

    </td>

    </tr>

    <tr><td>

    <%

          if (op instanceof String)
             {
                str = (String) op;

           %>
                <br>
                <br>
                <br>  
                <br>
                <br>
                <br>
                <center><font>

           <%  
                out.println( str);
             }

    %>
             </font></center>

    </td>

    </tr>

    <center><tr align="center"><td align="center"><input type=button value="CLOSE"  onClick="return winClose()" ></td></tr></center>
     
    </table>

    </center>

    </body>

    </html>
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    sorry it seems u send me another file the tags in the error like </DetailDate> is not in the file
    0
     

    Author Comment

    by:g46905
    I thought that you had asked me for .jsp file.This is where I am calling the method and getting the content of the file in a vector.
    Please let me know what exactly you are loking for?

    Thanks so much!
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    hay the problem is in the xml file u try to read into jso, try first to display this file directly into the browser it will not display
    0
     

    Author Comment

    by:g46905
    petmagdy,
                  I was able to open the .xml file without any problem in the browser.I dont think the problem is with the XML file as I have this issue with all the files.
    Also, we have a internal translator and this will throw an error if there is a probelm with the XML formatting.I believe that there is something in the code which needs
    to be changed to display the .Xml file along with the other text files.Also, The .XML file is being displayed, but the tags ("<" and ">" ) are missing. Could you please help me


    I appreciate all your effort.

    Thanks
    0
     

    Author Comment

    by:g46905
    Could some please give me some suggestions regarding the issue that I am facing above.Thanks for your help
    0
     
    LVL 13

    Accepted Solution

    by:
    sorry for the delay, see this html file:
    ============================================
    <%@ page contentType="text/html; charset=windows-1252"%>

        &#60;name&#62;john&#60;&#8260;name&#62;
    ===================================

    it is displayed correctly in ur browser and without changing ur content type it is still (text/html)

    < replaced by &#60;
    > replaced by &#62;
    / replaced by &#8260;

    so u get the file string and replace each of those with correspondent Hexadecimal value
    0
     

    Author Comment

    by:g46905
    petmagdy,
                  I am trying to make sure that we both are on the same page.Currently, if its a text file,I replace all null values of the string
    with &nbsp.Similar to this,do you want me to replace

    '<' by &#60;
    '>' by  &#62;
    '/'  by &#8260;

    Please let me know.Thanks again
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    yes

    Good luck
    0
     

    Author Comment

    by:g46905
    It displays the desired results after making the changes suggested.Thanks for your help.I would like to keep this open until I am done
    unit testing.It should take about tow days.Thanks for your patience.

    Thanks again,
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    welcome :)
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now