Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-10-28
20
Medium Priority
?
178 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
Comment
Question by:g46905
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 10
20 Comments
 
LVL 13

Expert Comment

by:petmagdy
ID: 12438167
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
ID: 12462502
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
ID: 12462550
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:g46905
ID: 12462626
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
ID: 12462634
yes please add
0
 

Author Comment

by:g46905
ID: 12462712
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
 
LVL 13

Expert Comment

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

Author Comment

by:g46905
ID: 12463489
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
ID: 12467798
please post the complete jsp code
0
 

Author Comment

by:g46905
ID: 12467829
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
ID: 12467937
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
ID: 12467973
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
ID: 12468796
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
ID: 12472593
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
ID: 12477998
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:
petmagdy earned 500 total points
ID: 12478461
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
ID: 12482358
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
ID: 12482482
yes

Good luck
0
 

Author Comment

by:g46905
ID: 12494497
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
ID: 12494825
welcome :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

636 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