I am using Java (JSP and Servlets) but am stuck. From my research I believe I might need a session level object
The user completes a JSP form, presses submit, and it is POST to the class NewServlet.
Inside NewServlet an object NewFileThing is created, where this information is stored.
@WebServlet(urlPatterns = {"/NewServlet"})
public class NewServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Stuff happens here...
String nameOfUser = request.getParameter("name");
NewFileThing fi = NewFileThing();
fi.addName(name);
response.sendRedirect("nextForm");
}
}
The user is then redirect to nextForm.jsp. When they complete this form they are sent to FinalServlet.
@WebServlet("/FinalServlet")
@MultipartConfig
public class FinalServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO how can I access object fi (NewFileThing) from here?
fi.getName(); <--- Error, or if I make new object it's NULL...
}
}
Question: Within FinalServlet, how can I get the same object NewFileThing I created earlier (same instance)? I do not want to create a new one!
Thank you lovely community!