import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class H extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		    Thread thread=new MyThread(request);
		    thread.start();
	}

}
class MyThread extends Thread{
	HttpServletRequest httpServletRequest=null;
	public MyThread(HttpServletRequest httpServletRequest){
		this.httpServletRequest=httpServletRequest;
		System.out.println("构造方法中"+httpServletRequest.getSession());
	}
	 @Override
	public void run() {
		while(true){
			try {
				Thread.sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			System.out.println("我是线程------"+this.getName());
			System.out.println("run方法中"+httpServletRequest.getSession());
		}
	}
}
/*为什么上面输出httpServletRequest.getSession()的值是null,输出httpServletRequest的值就不是null呢?*/
jsp方面:--------------------------
<script type="text/javascript">
         $(function(){
             $("#b1").click(function(){
                 $.get("H",{},function(message,stutes){
                 alert(message+"--------------------");


              });    
             });


           });
         
    </script>
 <input type="button" id="b1" value="Click me" />