• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

getting exception in JSF Tutorial of JR

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I copied all the files as it is, explained in JSF Tutorial of JR, but getting this exception:





Thanks.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you set your class path?? Please place these files in lib folder of tomcat and include these jar files in your class path.

servlet-api.jar
jsp-api.jar
jsf-api.jar
jsf-impl.jar

Hope it works.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Awais Sheikh:
Have you set your class path?? Please place these files in lib folder of tomcat and include these jar files in your class path.

servlet-api.jar
jsp-api.jar
jsf-api.jar
jsf-impl.jar

Hope it works.



I have these files in class path.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even when I try to view this simple JSP, I get exception:



It shows that, even f:view is not working... what could be the reason, I have both the JAR files required by JSF in class path.



Thanks.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to handle second example (simple jsp file), but finding very surprise behaviour:

1. I created one more file, test.faces (name of jsp file is also test (test.jsp)), which has the same code of jsp file (test.jsp)

2. I changed mapping in web.xml like this:



Now, I am able to see the output of test.jsp when I open test.faces (http://localhost:8081/JSFLogin/pages/test.faces).

If I try to view jsp file (http://localhost:8081/JSFLogin/pages/test.jsp), then I get this exception:





And If I change test.jsp and keep test.faces as it is, and I open test.faces, then I can see the changes done by me (so actually it is the output of jsp file but still browser has this URL: http://localhost:8081/JSFLogin/pages/test.faces)


very-very confused.


Thanks.
[ July 06, 2006: Message edited by: rathi ji ]
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rathi ji:
I managed to handle second example (simple jsp file), but finding very surprise behaviour:

1. I created one more file, test.faces (name of jsp file is also test (test.jsp)), which has the same code of jsp file (test.jsp)

2. I changed mapping in web.xml like this:



Now, I am able to see the output of test.jsp when I open test.faces (http://localhost:8081/JSFLogin/pages/test.faces).

If I try to view jsp file (http://localhost:8081/JSFLogin/pages/test.jsp), then I get this exception:





And If I change test.jsp and keep test.faces as it is, and I open test.faces, then I can see the changes done by me (so actually it is the output of jsp file but still browser has this URL: http://localhost:8081/JSFLogin/pages/test.faces)


very-very confused.


Thanks.

[ July 06, 2006: Message edited by: rathi ji ]



I can guess, what's actually happening:

A JSF page, has to be viewd from FacesServlet. So when I try to view test.jsp, I get exception because there is no such mapping for *.jsp files.

When I see test.faces in browser, it actually calls FacesServlet service() method, and in that service() method, service() method of test.java (something similer to that) is called (there is some logic written in FacesServlet, which sees the file name (in my case, test) and calls a class which has this name)... now the test.java is actually generated from test.jsp so content of this jsp file is rendered on browser...

Does it making any sense???
:roll:
 
Saloon Keeper
Posts: 25608
183
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That first step is the hardest, isn't it?

Let's see if I can help.

First, define your JSF pages as ".jsp" files, except that you'll need an <f:view> in them to wrap the JSF tags.

Next, setup a URL mapping in web.xml:


Some prefer "/faces/" as part of the URL pattern.

Now build a WAR and fire up the webapp. To get the JSF rendition of "hello.jsp", type in the URL: <a href="http://localhost:8080/mywebapp/hello.<b rel="nofollow">jsf</b>" target="_blank">http://localhost:8080/mywebapp/hello.jsf . Your URL may vary depending on host port and app context name.

If you invoke <a href="http://localhost:8080/mywebapp/hello.<b rel="nofollow">jsp</b>," target="_blank">http://localhost:8080/mywebapp/hello.jsp, you'll bypass the Faces servlet and get errors. The Faces servlet knows to drop the ".jsf" and add a ".jsp" when it goes to build the view page.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tim Holloway:
That first step is the hardest, isn't it?

Let's see if I can help.

First, define your JSF pages as ".jsp" files, except that you'll need an <f:view> in them to wrap the JSF tags.

Next, setup a URL mapping in web.xml:


Some prefer "/faces/" as part of the URL pattern.

Now build a WAR and fire up the webapp. To get the JSF rendition of "hello.jsp", type in the URL: jsf[/b]]http://localhost:8080/mywebapp/hello.jsf . Your URL may vary depending on host port and app context name.

If you invoke jsp[/b],]http://localhost:8080/mywebapp/hello.jsp, you'll bypass the Faces servlet and get errors. The Faces servlet knows to drop the ".jsf" and add a ".jsp" when it goes to build the view page.



Thansk Tim.

I did what all you mentioned...

But when I access file with jsf extension (http://localhost:8081/JSFLogin/pages/test.jsf), container try to find test.jsp and gives '404 - page not found' exception. Because of the reason you given: "The Faces servlet knows to drop the ".jsf" and add a ".jsp" when it goes to build the view page"...


 
Awais Sheikh
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can write your own extensions what ever u want as I am using my own names extensions. .

You wrote "Now, I am able to see the output of test.jsp when I open test.faces (http://localhost:8081/JSFLogin/pages/test.faces)".
You write test.faces instead of test.jsp because in mapping file you mentioned ".faces" extension in url-pattern.
Now, Mr. Tim used ".jsf" in url-pattern in web.xml thats why he wrote hello.jsf.
So, make it sure that you have changed in your web.xml file and restared your webserver after deploying war file.
Hope this will help you, if you have any other confusion feel free to ask.

Thanks,
Awais
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Awais Sheikh:
You can write your own extensions what ever u want as I am using my own names extensions. .

You wrote "Now, I am able to see the output of test.jsp when I open test.faces (http://localhost:8081/JSFLogin/pages/test.faces)".
You write test.faces instead of test.jsp because in mapping file you mentioned ".faces" extension in url-pattern.
Now, Mr. Tim used ".jsf" in url-pattern in web.xml thats why he wrote hello.jsf.
So, make it sure that you have changed in your web.xml file and restared your webserver after deploying war file.
Hope this will help you, if you have any other confusion feel free to ask.

Thanks,
Awais



Thanks Awais, I know this.

You read my previous post carefully, my doubt is different.
:roll:
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, did you find the solution to this problem? I still don't get why the hello.jsf tries to find the hello.jsp ... let me know the solution if you know it.

Thanks!
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic