1

We are integrating new application with existing JSP application and trying to re use some of existing functionality. I have a navigation rule in faces-navigation.xml like

<from-view-id>/WEB-INF/jsp/admin/login.xhtml</from-view-id>
<navigation-case>
    <from-outcome>success</from-outcome>
    <to-view-id>/WEB-INF/jsp/admin/welcome.xhtml</to-view-id>
</navigation-case>
<navigation-case>
    <from-outcome>admin</from-outcome>
    <to-view-id>/WEB-INF/jsp/admin/dashaboard.xhtml</to-view-id>
</navigation-case>
</navigation-rule>  

In my jsp I am trying to call this definition like

<a href="/WEB-INF/jsp/admin/login.xhtml">Admin login </a>

When I click on "Admin Login", I get page not found exception.

Is there another way to call this view ?

vsingh
  • 6,365
  • 3
  • 53
  • 57

1 Answers1

1

Files in /WEB-INF are not publicly accessible (i.e. the enduser can't open any files in /WEB-INF directly by entering its bare URL in browser's address bar). They are only accessible by a servlet which does a RequestDispatcher#forward() on the file in /WEB-INF folder. The old webapp code setup was apparently using such a servlet, either homegrown or from a different MVC framework.

You should be moving those pages to outside the /WEB-INF folder. I would by the way also remove the misleading /jsp part from the path as those files are not JSP files at all. Given the .xhtml extension, you are instead actually using its successor Facelets.

By the way, navigation rules are obsolete since JSF 2.0 thanks to the new "implicit navigation" feature. Perhaps you was focusing too much at JSF 1.x targeted books/tutorials while learning JSF?

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • You are right. This is 5 year old application built on JSF 1.2 and then partially migrated to JSF 2.0. I will move the files outside the WEB-INF and see if that helps. I was also using pretty faces to solve this problem but guess that would be a overkill. – vsingh Aug 08 '12 at 13:36
  • That was it BalusC. Such a simple stuff. Removed the folders from WEB-INF and they all were accessible – vsingh Aug 09 '12 at 13:58
  • @BalusC, I have a [question](http://stackoverflow.com/questions/18037884/jsf-implicit-vs-explicit-navigation) about you're last comment. Could you take a look? – neizan Aug 04 '13 at 07:35