I am new to struts2. I was trying a small application for practice but I hit an issue.
I was trying to forward directly from index.jsp to login.jsp. I know I can directly forward to login.jsp but the below code should also be valid. I am attaching the code I was trying.
below is the code from what I was trying.
index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Home</title>
</head>
<body>
<jsp:forward page="login.action" />
</body>
</html>
struts.xml
<struts>
<include file="example.xml"/>
<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="login">
<result>/login.jsp</result>
</action>
</package>
</struts>
login.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<s:form>
<s:textfield name="user" label="User Name" />
<s:password name="passwd" label="Password" />
</s:form>
</body>
</html>
In web.xml the index.php page is set as welcome page. Suppose XYZ is the context name, when I put /XYZ/login its take to login page but when I put /XYZ/in the browser it give and resource not found error.
when I use <META HTTP-EQUIV="Refresh" CONTENT="0;URL=login.action"> again it works fine.
I am using tomcat7 as a web server. Why is this happening?
Not all the containers by default perform FORWARD to non-JSP resources –
<jsp:forward/>– to say container to do it please add the following mapping to web.xml: