01: /*
02: * InvalidateSession.java
03: *
04: * Created on August 6, 2007, 8:28 AM
05: */
06:
07: package com.rift.test;
08:
09: import java.io.*;
10: import java.net.*;
11:
12: import javax.servlet.*;
13: import javax.servlet.http.*;
14:
15: /**
16: *
17: * @author brett
18: * @version
19: */
20: public class InvalidateSession extends HttpServlet {
21:
22: /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
23: * @param request servlet request
24: * @param response servlet response
25: */
26: protected void processRequest(HttpServletRequest request,
27: HttpServletResponse response) throws ServletException,
28: IOException {
29: System.out.println("The test value is ["
30: + getInitParameter("test") + "]");
31: response.setContentType("text/html;charset=UTF-8");
32: HttpSession hsession = request.getSession();
33: hsession.invalidate();
34: response.sendRedirect("/ExampleWebApplication");
35: }
36:
37: // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
38: /** Handles the HTTP <code>GET</code> method.
39: * @param request servlet request
40: * @param response servlet response
41: */
42: protected void doGet(HttpServletRequest request,
43: HttpServletResponse response) throws ServletException,
44: IOException {
45: processRequest(request, response);
46: }
47:
48: /** Handles the HTTP <code>POST</code> method.
49: * @param request servlet request
50: * @param response servlet response
51: */
52: protected void doPost(HttpServletRequest request,
53: HttpServletResponse response) throws ServletException,
54: IOException {
55: processRequest(request, response);
56: }
57:
58: /** Returns a short description of the servlet.
59: */
60: public String getServletInfo() {
61: return "Short description";
62: }
63: // </editor-fold>
64: }
|