
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Binder extends HttpServlet
{  
  public  void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
    {  //获得一个向客户发送数据的输出流：
       response.setContentType("text/html;charset=GB2312");//设置响应的MIME类型。
       PrintWriter out=response.getWriter();
       
       
       HttpSession session=request.getSession(true);  //获取客户的会话对象
       SessionObject o=new SessionObject();
       session.setAttribute("binder",o); 
       out.println("<HTML>"); 
       out.println("<head>");
       out.println("<title>Session Binding</title>");
       out.println("<head>");
       out.println("<BODY>"); 
       out.println("Object bound to session"+session.getId());               //获取会话的Id.
        out.println("</BODY>");
       out.println("</HTML>");
	session.removeAttribute("binder");
       out.flush();
    }
  
}