• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 183
  • Last Modified:

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

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
g46905
Asked:
g46905
  • 10
  • 10
1 Solution
 
petmagdyCommented:
the jsp should be like this:

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

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


//////////////////////////////////////////////////
page type should be text/xml
0
 
g46905Author Commented:
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
 
petmagdyCommented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
g46905Author Commented:
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
 
petmagdyCommented:
yes please add
0
 
g46905Author Commented:
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' 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
 
petmagdyCommented:
apparantly a tag is not closed probably at line 44 position 9
0
 
g46905Author Commented:
My file doesnt contain so many lines.I wonder why it specifies line 44? Could you please help me?

Thanks
0
 
petmagdyCommented:
please post the complete jsp code
0
 
g46905Author Commented:
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
 
petmagdyCommented:
sorry it seems u send me another file the tags in the error like </DetailDate> is not in the file
0
 
g46905Author Commented:
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
 
petmagdyCommented:
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
 
g46905Author Commented:
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
 
g46905Author Commented:
Could some please give me some suggestions regarding the issue that I am facing above.Thanks for your help
0
 
petmagdyCommented:
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
 
g46905Author Commented:
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
 
petmagdyCommented:
yes

Good luck
0
 
g46905Author Commented:
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
 
petmagdyCommented:
welcome :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 10
  • 10
Tackle projects and never again get stuck behind a technical roadblock.
Join Now