Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to clear request parameter from the previous servlet invocation

843841Jun 19 2004 — edited Jun 20 2004
Dear 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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 18 2004
Added on Jun 19 2004
1 comment
445 views