So I have one html form in “File1.html”
<form action="MyServlet" method="post">
MyData: <input type="text" name="data"><br>
<input type="submit" value="submit">
</form>
Then in my servlet I do the following:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
RequestDispatcher myDispatch = request.getRequestDispatcher("File2.html");
myDispatch.forward(request, response);
}
So after the user hits the “submit” button in File1, the servlet takes the user to File2. But how do I access the data that was inputed in the first file in the second file?
before using the Dispatcher set the attribute you want to pass
in your case
and on the dispached page , get it by