This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSF and the fly likes test.jsf works test.jsp doesn't Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » JSF
Bookmark "test.jsf works test.jsp doesn Watch "test.jsf works test.jsp doesn New topic

test.jsf works test.jsp doesn't

Mark Kelsall

Joined: Apr 23, 2011
Posts: 19
Hi Guys,

I'm new here & relatively new to java. I've been at it in SAP for the last year or so & i've been quite protected from real Java. So now i want to get my teeth into something...

I have been trying to understand the best way to put dynamic data into my .jsp page & found out that JSF is the way forward...right? I managed to find a tutorial working first time (pretty much) with test.jsf (even though i generated a test.jsp file according to eclipse). However i want it to display as test.jsp on my URL & that's how i would like to navigate to it through from other pages.

Is this possible? I have tried playing with my web.xml & changing the url-pattern, however this just seems to make it throw lots of errors & the faces-context error catching thingy page shows.

Thanks in advance!

Tuna Töre
Ranch Hand

Joined: Aug 17, 2008
Posts: 220

Just read this post as a starting point;



Core Spring Certified Professional + SCJP 6.0 + SCWCD 1.5
Mark Kelsall

Joined: Apr 23, 2011
Posts: 19
Thanks, i read the other post, however it doesn't quite make sense yet.

In my web.xml i have the following...

If i navigate to http://localhost:8080/mywebapp/jsf/test.jsp it tells me that the FacesContext cannot be found, however if i navigate to http://localhost:8080/mywebapp/jsf/test.jsf it finds the page & displays the contents correctly.


Emmanuel Borges

Joined: Mar 25, 2011
Posts: 12

Have you tried to change the pattern to *.jsp ? This way, all your JSP's will be interpreted as JSF files and processed by Faces Servlet. But I don't know if that is advisable.

In my application, I use xhtml files and the url pattern is *.xhtml
Mark Kelsall

Joined: Apr 23, 2011
Posts: 19
Hi Emmanuel,

Yeah i've tried changing it to *.jsp, unfortunately that just throws lots of errors.

I think that is the sort of thing i am looking for, best practices, things like using *.xhtml

Does that mean that when you a coding links to & from jsp pages with JSF in them, you link to .xhtml?

An example maybe:

create test.jsp page with JSF in, in my folder in my web app.
from another jsp page (say hello.jsp), an <a> tag would be:

<a href="http://localhost:8080/mywebapp/test.xhtml">to test</a>


It is sorta covered in the JavaRanch Style Guide.
subject: test.jsf works test.jsp doesn't
It's not a secret anymore!