I have created a login page which authenticates a user via the atuthentication class. After authentication I am using the following statement is to redirect to a JSP page.
response.sendRedirect("welcome.page");
This should look for the tiles-defs.xml for the mapping to an actual jsp page. I have provided this as follows
<definition name="main.layout" path="/mainLayout.jsp">
<put name="header" value="/header.jsp"/>
<put name="info" value="/info.jsp"/>
<put name="menu" value="/menu.jsp"/>
<put name="body" value=""/>
<put name="footer" value="/footer.jsp" />
</definition>
<definition name="welcome.page" extends="main.layout">
<put name="title" value="Welcome"/>
<put name="body" value="/welcome.jsp"/>
</definition>
I have created the mainLayout.jsp and the welcome.jsp pages. Now when a user has been authenticated it must redirect to welcome.jsp. But I am getting a “The webpage cannot be found” error. I guess the mapping is not correct which is why it is not able to find welcome.jsp, but I cannot figure out where I went wrong.
You can’t redirect to a tile definition. A redirect consists in sending a response to the browser telling him: “please go to the following URL”. A tile definition is not a URL.
You can redirect to a JSP, and the JSP will be executed. It’s bad practice though, because in a properly designed MVC application, all the requests should go through a controller. And you can redirect to the URL of an action of course, which is what you should do: redirected to the
welcome.doURL (assumingwelcome.dois the URL of the Struts welcome action)