Hello,
I am new to
JSF and trying to learn. I researched this but I was not able to find any solution. It is possible that I am trying to do something that is not possible.
Here is what I am trying to do:
I am trying a simple
test to see how navigation works. I was able to a navigate to
JSP page using navigation rule with no problem. I now wanted to see if I can navigate to a
servlet so I changed <to-view-id> element to point to a servlet rather than a JSP. First of all can I even do that? I would think that this should be possible as JSP is compiled into a servlet. However all tutorials and examples so reference for <to-view-id> to a JSP or xhtml files.
Below is a snippet of my faces-config.xml and web.xml. When I access the address
http://localhost:8080/adminTool/faces/saveServlet, the servlet loads fine. However when I click on a button on
http://localhost:8080/adminTool/faces/test.jsp, I get the message:
type Status report
message/saveServlet not found
descriptionThe requested resource (/saveServlet not found) is not available.
Any help in the matter will be greatly appreciated.
Thanks in advance.
faces-config.xml
<navigation-rule>
<from-view-id>test.jsp</from-view-id>
<navigation-case>
<from-outcome>saveServlet</from-outcome>
<to-view-id>saveServlet</to-view-id>
</navigation-case>
</navigation-rule>
web.xml :
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>saveServlet</servlet-name>
<servlet-class>com.mypackage.saveServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>saveServlet</servlet-name>
<url-pattern>/faces/saveServlet</url-pattern>
</servlet-mapping>