How to clear request parameter from the previous servlet invocation
843841Jun 19 2004 — edited Jun 20 2004Dear all,
I have a form uses POST to send some parameters to a servlet. I want to prevent users from accessing the servlet directly by typing in the address bar. Here are the codes:
index.htm
<html><body>
<form method=post actioin=servlet/SubscribeServlet>
Email <input type=text name=email><br>
<input type=submit>
</form>
</body></html>
SubscribeServlet
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class SubscribeServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
res.sendRedirect("...");
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws IOException, ServletException {
...
}
}
I access index.htm and input some values in the form to run the servlet. Tthe second time I acces the servlet directly to test the doGet method. Seems that it always runs the doPost method so it never redirect to the home page. Please help me on this. Thank you so much.
Joey