0

This is my JSF file header:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 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"
  xmlns:p="http://primefaces.org/ui">
<h:head>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"/>
    <title>#{txt.TXT_TITLE_LOGIN}</title>
    <link rel="stylesheet" type="text/css" href="scripts/styles.css"/>
    <link rel="shortcut icon" href="./images/favicon.ico"></link>
    <script src="./scripts/scripts.js" type="text/javascript"/>
</h:head>
<body...

When I opent the page, styles are not loaded, looks very ugly, and Firebug shows this:

<link href="scripts/styles.css" type="text/css" rel="stylesheet">
    The resource from this URL is not text: http://localhost:8080/EWC/scripts/styles.css
</link>

... but the file is there, at the location /EWC/scripts.

When I open some other page with very same header all is ok. Then I go back to this page and it is ok too. But it happens again when this page is loaded first after clean browser cash.

What went wrong?

Danijel
  • 8,198
  • 18
  • 69
  • 133
  • 1
    Are you able to hit the URL http://localhost:8080/EWC/scripts/styles.css on browser and see the content ? What are the response headers ? – Avinash Singh Mar 19 '13 at 18:15

1 Answers1

0

Resolved it.
Seams like the problem was conntected to Authorization redirect on session expiration does not work on submitting a JSF form, page stays the same.

The following code did not catch css file requests, so they were forwarded to Login page via gotoLogin() (in case user is not logged in).

if( requestURI.startsWith(req.getContextPath() + ResourceHandler.RESOURCE_IDENTIFIER) )
    chain.doFilter(request, response);
    return;
else
    gotoLogin(null, request, response);
    return;

I have added

if( requestURI.endsWith("css") )
    chain.doFilter(request, response);
    return;

...and it works.

As BalusC said, I hould have used <h:outputStylesheet>, <h:outputScript> and <h:graphicImage> instead of <link>, <script> and <img> in the header, and this would never happen.

Community
  • 1
  • 1
Danijel
  • 8,198
  • 18
  • 69
  • 133