Having two pages page1
and page2
in a web application.Page page1
is a facelet based on an .xhtml file and page2
is generated by a servlet.
Let's assume page1.xhtml
looks like this:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="jakarta.faces.html" xmlns:f="jakarta.faces.core"><h:head><title>TODO supply a title</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/></h:head><h:body><h:button outcome="yolo" value="move on"/></h:body></html>
And for the sake of simplicity let page2
be generated from the following servlet:
package tests;import jakarta.inject.Inject;import jakarta.servlet.ServletException;import jakarta.servlet.annotation.WebServlet;import jakarta.servlet.http.HttpServlet;import jakarta.servlet.http.HttpServletRequest;import jakarta.servlet.http.HttpServletResponse;import java.io.IOException;@WebServlet(urlPatterns = "/abc")public class StorageSrv extends HttpServlet { @Inject private Storage storage; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.getWriter().write("abc"); }}
I have also added a navigation rule to the faces-config.xml
as follows:
<navigation-rule><from-view-id> /flexible.xhtml</from-view-id><navigation-case><from-outcome> yolo</from-outcome><to-view-id> /abc</to-view-id></navigation-case></navigation-rule>
How can I redirect from page1
to page2
?Currently the navigation rule adds .xhtml extension so by clicking the "move on" button on page1
I get 404.