Reputation: 71
<p>
<form action="logout.java" method="post">
<input type="button" value="Logout">
</form>
</p>
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.sendRedirect("login.jsp");
}
but when i click the button nothing happens?
Upvotes: 1
Views: 15357
Reputation: 19
Use this:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.getRequestDispatcher("/login.jsp").forward(request, response);
}
Upvotes: 0
Reputation: 1855
You have to use a submit input :
<input type="submit" value="Logout">
Make sure the servlet which contains the doPost()
method is mapped to logout.java
. If not, you have to set the action in your form tag.
Upvotes: 2