0

When running my JSF "Hello World" in server I get a File download message box which says "do you want to save this file, or find a program online to open it" which has three options find, save and cancel. When I click on 'find' following message is shown

"Windows has the following information about this MIME type. This page will help you find software needed to open your file.

MIME Type: application/xhtml xml

Description: UnKnown

Windows does not recognize this MIME type."

my xhtml is

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets">

<h:head>
    <title>Insert title here</title>
</h:head>
<h:body>
    <f:view>
        <h:outputText value="Hello World"></h:outputText>   
    </f:view>
</h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">
    <display-name>hospital</display-name>
    <welcome-file-list>
        <welcome-file>login.xhtml</welcome-file>

    </welcome-file-list>

    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
</web-app>

If I run that particular xhtml file then its shown in IE. But any update to xhtml file will will be shown after refreshing the IE.

I am using Eclipse-helios IDE, Glassfish webserver. Thanks in advance

Johny T Koshy
  • 3,857
  • 2
  • 23
  • 40

1 Answers1

3

MSIE does indeed not support the content type of application/xhtml+xml. The page should be served with a content type of text/html (you can verify that with HTTP/web developer tools). But that should already be done by default JSF/Facelets configuration. You don't seem to have overridden the content type anywhere in the given code. One of the ways is defining it using the contentType attribute of the <f:view> tag. Another way is calling HttpServletResponse#setContentType() in some web filter. Or, completely different, perhaps it's been done afterwards by the webserver itself or by some proxy in the line.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks a lot for assisting. I had added text/html to f:view content type. But it wasnt working in the workspace that I was using. But now after seeing your answer I created a new workspace and tried it again as you suggested and it works. But after running the server to view the changes that I make in xhtml page the first time it always shows the old content but when I refresh the new content is shown. Should I ask this one as another question? – Johny T Koshy Jul 17 '11 at 16:09
  • 1
    Wait, which browser were you using? The Eclipse-buitin one or an independent webbrowser? You should prefer using an independent browser (Firefox, Chrome, IE, etc) over Eclipse-builtin one. – BalusC Jul 17 '11 at 20:46