Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URL opens showing html code not the page

Status
Not open for further replies.

browerv

Programmer
Jan 24, 2012
7
US
I'm working with an SOA vendor who provides a URL that looks like this:
It's supposed to be a URL which returns an HTML string that should show as a web page.
When I use it in a browser, IE or Firefox it shows the html code and seems to treat it as an XML document instead of showing the actual data.
Can someone explain why my browsers don't render the page from the html string it gets back?

The plan was to use the URL as the source in an iframe but all the frame shows is the source below:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<html><head><META http-equiv="Content-Type" content="text/html; charset=utf-16"/><style type="text/css">

th.th_title
{ border-bottom-width : 0px; }

th {
font: bold 14px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
color: #4f6b72;
border-bottom: 1px solid #C1DAD7; text-align: Center;
padding: 2px 1px 2px 10px; }

th.papertype
{
font: bold 14px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px solid #C1DAD7;
padding: 2px 1px 2px 1px;
color: #4f6b72;
text-align: left ;
width:75px;
}

td
{
font: 12px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px solid #C1DAD7;
background: #fff; padding: 2px 5px 5px 10px;
color: #4f6b72; width:65px; text-align:right ;
}

td.papertype
{
font: 12px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;

border-bottom: 1px solid #C1DAD7; background: #fff; padding: 2px 1px 2px 1px;
color: #4f6b72; text-align: left ; width:75px;
}

td.dollar_col
{
font: 12px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;

border-bottom: 1px solid #C1DAD7; background: #fff; padding: 2px 5px 2px 2px;
color: #4f6b72; width:70px; text-align:right ;
}

td.papertypetotal
{
font: bold 12px "Trebuchet MS" , Verdana, Arial, Helvetica, sans-serif;
border-bottom: 1px solid #C1DAD7; background: #fff; padding: 2px 5px 2px 1px;
color: Black ; width:75px; text-align: left ;
}
</style></head><body><table><tr><th colspan="4" class="th_title">Today's Orders </th></tr><tr><th class="papertype"> Type </th><th>Stock #'s </th><th>Special #'s </th><th>Total$ </th></tr><tr><td class="papertype">Writing</td><td>47,517 </td><td>1,320 </td><td>48,837 </td></tr><tr><td class="papertype">T & C</td><td>204,849 </td><td>159,422 </td><td>364,271 </td></tr><tr><td class="papertype">SPECIALTY</td><td>19,721 </td><td>0 </td><td>19,721 </td></tr><tr><td class="papertype">Opague</td><td>4,590 </td><td>0 </td><td>4,590 </td></tr><tr><td class="papertype">COLOR COPY</td><td>67,400 </td><td>0 </td><td>67,400 </td></tr><tr><td class="papertype">Coated</td><td>50,690 </td><td>6,075 </td><td>56,765 </td></tr><tr><td class="papertype">Brights</td><td>38,117 </td><td>0 </td><td>38,117 </td></tr><tr><td class="papertypetotal">Total</td><td>432,884 </td><td>166,817 </td><td>599,701 </td></tr></table></body></html>

Vince
 
The table seems to be showing correct tabular data of names and values so it is correct.

Other than than that, the file might not have ithe correct headers for it causing it to show up as regular text.
Personally I would use some type of server side programming language to read in the file, strip the unnecessary HTML, and output the rest out into the regular page.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I was in a hurry and probably could have provided more background.
I consider myself an intermediate level web developer. I know how to set up IIS and web sites for my own use. In this case I have no control over the architecture behind the URL, it's an outside service provider. They don't want to host a web site/page, their core business is data transformation/translation as a service. When I click the link it does return the aforementioned HTML string, but a browser treats it as just a string of data to display. I'll attach an image of the browser window resulting from clicking the URL.
I was hoping for an explanation as to why a browser just displays the returned string of data and doesn't understand it's html to be rendered as a webpage.
My hunch is that the source may not be a web server and since the URL has no extension such as html,htm,aspx, etc. the client and server aren't communicating exactly what type of content is being returned.

darryncooke, regarding your table comment, you didn't mention and reasons behind the opinion. In this case I believe I'm displaying private tabular data (no SEO to worry about). While there are many opposing opinions on the subject this link below leads me to belive it's not a big deal to use a table to display tabluar data in some cases. ALthough based on what I read I will avoid tables strictly for laying out non-tabular content, and use css.

Thanks for any feedback.






Vince
 
Thanks, vacunita. I did that while I was testing myself but here's the model:
I create an internal web service to return some order summary data but wrapped in all the neccessary HTMl and CSS to display as a webpage.
This outside service provider securely calls my web service to get the html string and is supposed to provide a URL that can be used in a Sugar CRM iframe for our external salesforce. When you use this URL in an iframe it just shows the html.
The service provider doesn't want to host a webpage and we're trying to also avoid web development within Sugar CRM. I'm starting to think I'm being asked to do the impossible by people above my pay grade.

Vince
 
Probably down to headers as I said. The file is being sent as plain text rather than HTML so the browser presents it as text.

Its not about hosting a webpage, its simply about sending the proper headers back from the service provider. Again, if you are hosting the page that will display this, why not simply read in the file using a programming language and simply output to a DIV within the webpage rather than an iframe.

Alternatively, you'll have to talk to the service provider and get them to append the proper headers to the data so it is rendered as HTML rather than text.





----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Why not use tables to layout a site (they are ok for tabular data)?

Simple, its a deprecated standard of code.

It's bulky to make edits as it combines the HTML and styling into one document, one can argue that you can use CSS, but you are greatly limited.

Semantically its incorrect.

It limits the ability with which you CAN layout a page.

Darryn Cooke
| Marketing and Creative Services
 
But he's not laying out a page, he's presenting tabular data.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Thanks for all the input. I'll definitely be careful about using tables only when truly appropriate, or maybe not at all if CSS handles all the requirements.
Regarding the original issue of the way the browser was displaying the result from the URL: I just spoke with a technical person from the organization supplying the URL. The URL hits a webservice and is returning "text/xml" in the header, they are working on a change to return "text/HTML" so that the browser recognizes it as a web page. Basically the webservice call will simulate a call to a webpage. Hopefully that will solve the problem.





Vince
 
Glad it got sorted.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top