You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Josué Alcalde González <ja...@csa.es> on 2006/11/08 10:11:24 UTC

Tomcat and JSF. Internet Explorer prompts for download

I am developing a JSF application using tomcat 5.5.20 and myfaces 1.1.4.

It works perfect in Firefox but IE doesn't show the faces pages, but it
prompts to download.

This is my web.xml file:

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

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  <display-name>paninfo-web</display-name>

  <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>

  <context-param>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
  </context-param>

  <filter>
    <filter-name>MyFacesExtensionsFilter</filter-name>

<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
    <init-param>
      <param-name>maxFileSize</param-name>
      <param-value>20m</param-value>
    </init-param>
  </filter>

  <!-- extension mapping for adding <script/>, <link/>, and other
resource tags to JSF-pages  -->
  <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <!-- servlet-name must match the name of your
javax.faces.webapp.FacesServlet entry -->
    <servlet-name>Faces Servlet</servlet-name>
  </filter-mapping>

  <!-- extension mapping for serving page-independent resources
(javascript, stylesheets, images, etc.)  -->
  <filter-mapping>
    <filter-name>MyFacesExtensionsFilter</filter-name>
    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
  </filter-mapping>
  <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>*.faces</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

</web-app>

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

and this is how it looks my first a .faces file:

---------------------------------------------------------------------------
<%@ page language="java" contentType="text/html charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<c:if test="${loginSessionBean != null}">
  <c:redirect url="usuarios.faces" />
</c:if>
<html>

<%@include file="inc/htmlhead.inc.html"%>

<body>

<f:view>

  <%@include file="inc/cabecera.inc.jsp"%>

  <h:form id="frLogin">
    <t:div styleClass="cont_login" id="cont_login">
      <t:div styleClass="login_izqda" id="login_izqda">
        <t:graphicImage id="giIcoAcceso" url="images/ico_acceso.gif"
          alt="Imagen de acceso" />
      </t:div>
      <t:div styleClass="login_dcha" id="login_dcha">
        <f:verbatim>
          <h2>Bienvenido</h2>
          <span class="mensajes">Por favor, introduzca sus datos para
proceder a la
          validación</span>
        </f:verbatim>
        <h:panelGrid columns="2" cellpadding="0" cellspacing="0"
          style="margin:5px 0 5px 0;">
          <h:outputLabel id="olLogin" for="itLogin" value="Usuario"
            style="margin-right:10px;" />
          <h:outputLabel id="olPassword" for="isPassword"
value="Contraseña" />
          <h:inputText id="itLogin" required="true" tabindex="0"
            style="margin-right:10px;" />
          <h:inputSecret id="isPassword" required="true">
            <f:validator
validatorId="es.csa.ubu.paninfo.web.validators.LoginValidator" />
          </h:inputSecret>
        </h:panelGrid>
        <h:commandButton value="Aceptar"
action="#{loginSessionBean.autenticacion}"
          styleClass="botones" />
      </t:div>

    </t:div>

    <t:div styleClass="errores" id="errores"
      rendered="#{! empty facesContext.maximumSeverity}">
      <h:panelGrid columns="1">
        <t:message id="mesLogin" for="itLogin" />
        <t:message id="mesPassword" for="isPassword" />
      </h:panelGrid>
    </t:div>
  </h:form>
</f:view>

</body>

</html>

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

What could be the problem? I have no ideas.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat and JSF. Internet Explorer prompts for download

Posted by Stephen Souness <so...@hotmail.com>.
I'm no JSF expert, but the following might get you somewhere...

Do you have a MIME type configured for the url extension(s) that you 
have for your JSF URLs?

I've also seen a recommendation to add the following directive:

<jsp:directive.page contentType="text/html"/>

on the Core JSF FAQ page.


--
Stephen


Christopher Schultz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Josué,
> 
> Josué Alcalde González wrote:
>> I am developing a JSF application using tomcat 5.5.20 and myfaces 1.1.4.
>>
>> It works perfect in Firefox but IE doesn't show the faces pages, but it
>> prompts to download.
> 
> MSIE is a pile of crap. Given your JSP code:
> 
>> <%@ page language="java" contentType="text/html charset=UTF-8"
>> pageEncoding="UTF-8"%>
>> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
>> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
>> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
>> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
>> <c:if test="${loginSessionBean != null}">
>>   <c:redirect url="usuarios.faces" />
>> </c:if>
>> <html>
> 
> You have a lot of stuff before the "<html>" header. MSIE ignores the
> Content-Type header that the server sends because it thinks it's smarter
> than the server. If it can't find something that looks like HTML in the
> first couple of bytes of the document, it craps its pants and uses
> "application/octet-stream" as the MIME type.
> 
> I recommend tweaking your JSP page so that your <html> comes as early in
> the page as possible. Try taking out some of the extra newlines between
> those <%@ taglib %> directives (seriously). Maybe even put the <html>
> above the <%@page %> directive if tht even works.
> 
> My guess is that this small, stupid change will fix your MSIE woes.
> 
> Great further reading on MSIE and the Content-Type:
> http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html
> 
> - -chris
> 
>> <%@include file="inc/htmlhead.inc.html"%>
>>
>> <body>
>>
>> <f:view>
>>
>>   <%@include file="inc/cabecera.inc.jsp"%>
>>
>>   <h:form id="frLogin">
>>     <t:div styleClass="cont_login" id="cont_login">
>>       <t:div styleClass="login_izqda" id="login_izqda">
>>         <t:graphicImage id="giIcoAcceso" url="images/ico_acceso.gif"
>>           alt="Imagen de acceso" />
>>       </t:div>
>>       <t:div styleClass="login_dcha" id="login_dcha">
>>         <f:verbatim>
>>           <h2>Bienvenido</h2>
>>           <span class="mensajes">Por favor, introduzca sus datos para
>> proceder a la
>>           validación</span>
>>         </f:verbatim>
>>         <h:panelGrid columns="2" cellpadding="0" cellspacing="0"
>>           style="margin:5px 0 5px 0;">
>>           <h:outputLabel id="olLogin" for="itLogin" value="Usuario"
>>             style="margin-right:10px;" />
>>           <h:outputLabel id="olPassword" for="isPassword"
>> value="Contraseña" />
>>           <h:inputText id="itLogin" required="true" tabindex="0"
>>             style="margin-right:10px;" />
>>           <h:inputSecret id="isPassword" required="true">
>>             <f:validator
>> validatorId="es.csa.ubu.paninfo.web.validators.LoginValidator" />
>>           </h:inputSecret>
>>         </h:panelGrid>
>>         <h:commandButton value="Aceptar"
>> action="#{loginSessionBean.autenticacion}"
>>           styleClass="botones" />
>>       </t:div>
>>
>>     </t:div>
>>
>>     <t:div styleClass="errores" id="errores"
>>       rendered="#{! empty facesContext.maximumSeverity}">
>>       <h:panelGrid columns="1">
>>         <t:message id="mesLogin" for="itLogin" />
>>         <t:message id="mesPassword" for="isPassword" />
>>       </h:panelGrid>
>>     </t:div>
>>   </h:form>
>> </f:view>
>>
>> </body>
>>
>> </html>
>>
>> ---------------------------------------------------------------------------
>>
>> What could be the problem? I have no ideas.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFFUlaH9CaO5/Lv0PARAqlUAKCzkaxVdW1I0sld3hXg6BtxrNqcigCdGnKN
> 3ZCRTY9k23QtwQuyHxt1y3U=
> =LkQX
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat and JSF. Internet Explorer prompts for download

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Josué,

Josué Alcalde González wrote:
> I am developing a JSF application using tomcat 5.5.20 and myfaces 1.1.4.
> 
> It works perfect in Firefox but IE doesn't show the faces pages, but it
> prompts to download.

MSIE is a pile of crap. Given your JSP code:

> <%@ page language="java" contentType="text/html charset=UTF-8"
> pageEncoding="UTF-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
> <c:if test="${loginSessionBean != null}">
>   <c:redirect url="usuarios.faces" />
> </c:if>
> <html>

You have a lot of stuff before the "<html>" header. MSIE ignores the
Content-Type header that the server sends because it thinks it's smarter
than the server. If it can't find something that looks like HTML in the
first couple of bytes of the document, it craps its pants and uses
"application/octet-stream" as the MIME type.

I recommend tweaking your JSP page so that your <html> comes as early in
the page as possible. Try taking out some of the extra newlines between
those <%@ taglib %> directives (seriously). Maybe even put the <html>
above the <%@page %> directive if tht even works.

My guess is that this small, stupid change will fix your MSIE woes.

Great further reading on MSIE and the Content-Type:
http://ppewww.ph.gla.ac.uk/~flavell/www/content-type.html

- -chris

> 
> <%@include file="inc/htmlhead.inc.html"%>
> 
> <body>
> 
> <f:view>
> 
>   <%@include file="inc/cabecera.inc.jsp"%>
> 
>   <h:form id="frLogin">
>     <t:div styleClass="cont_login" id="cont_login">
>       <t:div styleClass="login_izqda" id="login_izqda">
>         <t:graphicImage id="giIcoAcceso" url="images/ico_acceso.gif"
>           alt="Imagen de acceso" />
>       </t:div>
>       <t:div styleClass="login_dcha" id="login_dcha">
>         <f:verbatim>
>           <h2>Bienvenido</h2>
>           <span class="mensajes">Por favor, introduzca sus datos para
> proceder a la
>           validación</span>
>         </f:verbatim>
>         <h:panelGrid columns="2" cellpadding="0" cellspacing="0"
>           style="margin:5px 0 5px 0;">
>           <h:outputLabel id="olLogin" for="itLogin" value="Usuario"
>             style="margin-right:10px;" />
>           <h:outputLabel id="olPassword" for="isPassword"
> value="Contraseña" />
>           <h:inputText id="itLogin" required="true" tabindex="0"
>             style="margin-right:10px;" />
>           <h:inputSecret id="isPassword" required="true">
>             <f:validator
> validatorId="es.csa.ubu.paninfo.web.validators.LoginValidator" />
>           </h:inputSecret>
>         </h:panelGrid>
>         <h:commandButton value="Aceptar"
> action="#{loginSessionBean.autenticacion}"
>           styleClass="botones" />
>       </t:div>
> 
>     </t:div>
> 
>     <t:div styleClass="errores" id="errores"
>       rendered="#{! empty facesContext.maximumSeverity}">
>       <h:panelGrid columns="1">
>         <t:message id="mesLogin" for="itLogin" />
>         <t:message id="mesPassword" for="isPassword" />
>       </h:panelGrid>
>     </t:div>
>   </h:form>
> </f:view>
> 
> </body>
> 
> </html>
> 
> ---------------------------------------------------------------------------
> 
> What could be the problem? I have no ideas.
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFUlaH9CaO5/Lv0PARAqlUAKCzkaxVdW1I0sld3hXg6BtxrNqcigCdGnKN
3ZCRTY9k23QtwQuyHxt1y3U=
=LkQX
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat and JSF. Internet Explorer prompts for download

Posted by Martin Gainty <mg...@hotmail.com>.
Josue-

I cannot resolve http://java.sun.com/jsf/html from your index.jsp

Entiende?
M

This e-mail communication and any attachments may contain confidential and privileged information for the use of the 
designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received
this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its 
contents
----- Original Message ----- 
From: "Josué Alcalde González" <ja...@csa.es>
To: <us...@tomcat.apache.org>
Sent: Wednesday, November 08, 2006 4:11 AM
Subject: Tomcat and JSF. Internet Explorer prompts for download


>I am developing a JSF application using tomcat 5.5.20 and myfaces 1.1.4.
> 
> It works perfect in Firefox but IE doesn't show the faces pages, but it
> prompts to download.
> 
> This is my web.xml file:
> 
> ---------------------------------------------------------------------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app id="WebApp_ID" version="2.4"
> xmlns="http://java.sun.com/xml/ns/j2ee"
>  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
>  <display-name>paninfo-web</display-name>
> 
>  <context-param>
>    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
>    <param-value>client</param-value>
>  </context-param>
> 
>  <context-param>
>    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
>    <param-value>true</param-value>
>  </context-param>
> 
>  <context-param>
>    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
>    <param-value>false</param-value>
>  </context-param>
> 
>  <context-param>
>    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
>    <param-value>true</param-value>
>  </context-param>
> 
>  <context-param>
>    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
>    <param-value>true</param-value>
>  </context-param>
> 
>  <filter>
>    <filter-name>MyFacesExtensionsFilter</filter-name>
> 
> <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
>    <init-param>
>      <param-name>maxFileSize</param-name>
>      <param-value>20m</param-value>
>    </init-param>
>  </filter>
> 
>  <!-- extension mapping for adding <script/>, <link/>, and other
> resource tags to JSF-pages  -->
>  <filter-mapping>
>    <filter-name>MyFacesExtensionsFilter</filter-name>
>    <!-- servlet-name must match the name of your
> javax.faces.webapp.FacesServlet entry -->
>    <servlet-name>Faces Servlet</servlet-name>
>  </filter-mapping>
> 
>  <!-- extension mapping for serving page-independent resources
> (javascript, stylesheets, images, etc.)  -->
>  <filter-mapping>
>    <filter-name>MyFacesExtensionsFilter</filter-name>
>    <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
>  </filter-mapping>
>  <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>*.faces</url-pattern>
>  </servlet-mapping>
>  <welcome-file-list>
>    <welcome-file>index.html</welcome-file>
>    <welcome-file>index.htm</welcome-file>
>    <welcome-file>index.jsp</welcome-file>
>    <welcome-file>default.html</welcome-file>
>    <welcome-file>default.htm</welcome-file>
>    <welcome-file>default.jsp</welcome-file>
>  </welcome-file-list>
> 
> </web-app>
> 
> ---------------------------------------------------------------------------
> 
> and this is how it looks my first a .faces file:
> 
> ---------------------------------------------------------------------------
> <%@ page language="java" contentType="text/html charset=UTF-8"
> pageEncoding="UTF-8"%>
> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>
> <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
> <c:if test="${loginSessionBean != null}">
>  <c:redirect url="usuarios.faces" />
> </c:if>
> <html>
> 
> <%@include file="inc/htmlhead.inc.html"%>
> 
> <body>
> 
> <f:view>
> 
>  <%@include file="inc/cabecera.inc.jsp"%>
> 
>  <h:form id="frLogin">
>    <t:div styleClass="cont_login" id="cont_login">
>      <t:div styleClass="login_izqda" id="login_izqda">
>        <t:graphicImage id="giIcoAcceso" url="images/ico_acceso.gif"
>          alt="Imagen de acceso" />
>      </t:div>
>      <t:div styleClass="login_dcha" id="login_dcha">
>        <f:verbatim>
>          <h2>Bienvenido</h2>
>          <span class="mensajes">Por favor, introduzca sus datos para
> proceder a la
>          validación</span>
>        </f:verbatim>
>        <h:panelGrid columns="2" cellpadding="0" cellspacing="0"
>          style="margin:5px 0 5px 0;">
>          <h:outputLabel id="olLogin" for="itLogin" value="Usuario"
>            style="margin-right:10px;" />
>          <h:outputLabel id="olPassword" for="isPassword"
> value="Contraseña" />
>          <h:inputText id="itLogin" required="true" tabindex="0"
>            style="margin-right:10px;" />
>          <h:inputSecret id="isPassword" required="true">
>            <f:validator
> validatorId="es.csa.ubu.paninfo.web.validators.LoginValidator" />
>          </h:inputSecret>
>        </h:panelGrid>
>        <h:commandButton value="Aceptar"
> action="#{loginSessionBean.autenticacion}"
>          styleClass="botones" />
>      </t:div>
> 
>    </t:div>
> 
>    <t:div styleClass="errores" id="errores"
>      rendered="#{! empty facesContext.maximumSeverity}">
>      <h:panelGrid columns="1">
>        <t:message id="mesLogin" for="itLogin" />
>        <t:message id="mesPassword" for="isPassword" />
>      </h:panelGrid>
>    </t:div>
>  </h:form>
> </f:view>
> 
> </body>
> 
> </html>
> 
> ---------------------------------------------------------------------------
> 
> What could be the problem? I have no ideas.
> 
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
>

Re: Tomcat and JSF. Internet Explorer prompts for download

Posted by Josué Alcalde González <ja...@csa.es>.
El mié, 08-11-2006 a las 10:11 +0100, Josué Alcalde González escribió:

Thanks for your answers.

I will talk about my experiences with the solutions.

I try to define a mime-type in web.xml, but it didn't work.

Studying the source code in Internet Explorer (the file he tries to
download), I realize that <html> tag was in the 5 or 6 line.

And yes, it works if <html> is the first thing in the document.
I thougth the problem was not the lines, but that they were UNIX Line
delimeters, because I am working on linux.

I think IE tries to find <html> even if it is not in the firs line, but
it does not work with UNIX line delimeters.

So, that is the best solution: covert line delimeters to windows line
delimiters.



---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org