I want create 2 JSP pages. I have Controller:
@Controller
@RequestMapping(value = "/api/web/users")
public class ServletWebController {
@RequestMapping(method = RequestMethod.GET)
public String printWelcome(ModelMap model) {
model.addAttribute("message", "message");
return "hello";
}
}
It open first JSP page with form:
<html>
<body>
<form action="main.jsp" method="post">
First Name: <input type="text" name="first_name">
<br />
Last Name: <input type="text" name="last_name" />
<input type="submit" value="Submit" />
</form>
</body>
</html>
When I input data to the form and press submit button, I want to open second JSP page and print data from form:
<html>
<head>
<title>Using GET and POST Method to Read Form Data</title>
</head>
<body>
<center>
<h1>Using GET Method to Read Form Data</h1>
<ul>
<li><p><b>First Name:</b>
<%= request.getParameter("first_name")%>
</p></li>
<li><p><b>Last Name:</b>
<%= request.getParameter("last_name")%>
</p></li>
</ul>
</body>
</html>
But the second JSP page not opened. So I input http://localhost:4000/api/web/users
And i have form. Then I input data and press "Submit". Then I have this link http://localhost:4000/api/web/main.jsp
and error:
HTTP Status 404 - /api/web/main.jsp
type Status report
message /api/web/main.jsp
description The requested resource is not available.
Apache Tomcat/8.0.26
I am new in Spring and JSP, how can I open JSP from another JSP?