Issue with Invoking UserServlet after logging in successfully form LoginServet
Hitesh Patel Patel
posted 2 years ago
This is the objective: "How to invoke another servlet's GET method from current servlet?"
Scenario When login.jsp is submitted it calls the LoginServet servlet (form action). If login is OK then I need to redirect to user list page.
And user list page needs to have data-grid populated so instead of redirecting on userlist.jsp I call the UserServlet?action=list from LoginServlet.
But rather it calls the UserServet's POST method instead of GET method.
And UserServlet's POST method has logic of add/modify user so every time I login it just creates new record in the user table with entered username/password.
So can I get some help how to call GET method of UserServlet?
Which method is called depends solely on the request type that is stored in the HttpRequest instance. It works the same for all containers. Unless you specifically modify the request instances, all subsequent servlets will be called with the same method. So GET requests will never invoke doPost() unless you tamper with the request type..