I have jsp page (say, source.jsp
) with form:
<html>
<head>
<body>
<form action="Servlet123" method="POST">
// form fileds ...
</form>
</body>
</head>
</html>
And the required doPost
in servlet -
@WebServlet("/Servlet123")
public class Servlet123 extends HttpServlet {
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//use with requset...
}
}
How can I get the page (in this case - source.jsp
) sending the request to this servlet? Is there a method in request/session?
Use passing parameter in a request through a hidden field:
In your jsp page:
<form action="Servlet123" method="post">
<input type="hidden" name="namePage" value="sourcePage" />
</form>
In your servlet:
String namePage = request.getParameter("namePage");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With