1

The following is my index.html file which contains the JSF: http://pastie.org/3755252

When I choose Run as > Run on Server (Tomcat 7.0.12) in Eclipse Indigo I get a page which says only the following:

You have login attempts left. 

The same happens in Chrome. Although after looking at the source of the page, it displayed just as I have it written in Eclipse (the previous pastie file), but it seems like it should be translated to html.

This is my Member.java file: http://pastie.org/3755277 And here is my web.xml: http://pastie.org/3755284

It used to work, before I noticed I was mixing JSF 2.0 with JSF1.* syntax. Then I changed my *.jsp to *.html and it doesn't work.

2
  • Updated web.xml, with two versions and what each does: pastie.org/3759169 Commented Apr 10, 2012 at 1:23
  • The statement "it displayed just as I have it written in Eclipse" conflicts with the title. Please clarify the concrete problem. What do you see when you do rightclick and View Source in webbrowser? Do you really understand what it means when you say "EL" as in title? Commented Apr 10, 2012 at 16:25

1 Answer 1

3

Pastie seems to be down (I can't read your files)... but Tomcat isn't a full Java EE container. You'd need the Mojarra runtime. Do you have that included in your build?

EDIT: NM it's back. I see the JSF servlet in your web.xml, so you may disregard this answer.

EDIT2: Add this to your web.xml:

 <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.xhtml</param-value> </context-param> 

Then rename your .html files to .xhtml. I have a feeling the servlet didn't know it was supposed to render your files using JSF.

EDIT3: So I think what's happening is your confusing the server on whether or not it should render the page using Faces. You're URL in your url bar is "localhost/app/faces/index.html" which matches a file exactly. So should it do a sendfile or should it run it through the servlet? The reason why renaming to .xhtml likely worked was because internally it knew it had to map a .html request to a .xhtml file.

So maybe try renaming your files to .html5, then set this in your web.xml:

 <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.html5</param-value> </context-param> 

I think any extension will work... You could also do this combination:

 <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name> <param-value>.html</param-value> </context-param> 

Then your home page would be http://localhost/app/index.jsf

Sign up to request clarification or add additional context in comments.

14 Comments

I'm trying to use HTML5, would *.xhtml still be valid for HTML5? I've tried servlet mapping of the following ...<url-pattern>*.html<url-pattern>.. but the server keeps crashing when I tried loading the page.
First, notice that my XML isn't a servlet mapping, it's a context param. Next, you can change it to .html and it should still work. Do not change your servlet mapping, you already have it set correctly.
Ah, I tried to map the servlet and the context param at the same time before, but I didn't understand the idea behind the servlet mapping and I couldn't find any information on the context-param configuration. Thanks, I'll try your suggestion.
Tried it with .html but it did not work, but then I tried it with .xhtml and renamed my files to *.xhtml and that worked... So what's the problem with it reading .html?
So the servelet mapping maps external to the servlet. Then the context parm maps a servlet to the files. I imagine having them set to the same thing caused a problem... I'm not really sure to be honest.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.