import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.lang.*;

public class DispatcherServlet extends HttpServlet{
	public void init(ServletConfig config) throws ServletException{
		super.init(config);				
	}
	
	public void doGet(HttpServletRequest req,HttpServletResponse resp)
					throws IOException,ServletException{
						resp.setContentType("text/html;charset=gbk");
						PrintWriter out=resp.getWriter();		
		ServletContext thisContext=getServletConfig().getServletContext();
		String myname=(String)thisContext.getAttribute("MyName");
		System.out.println("ffff"+myname);
		RequestDispatcher myDispatcher;
		if(myname!=null&&myname.equals("zhanghz")){
		  myDispatcher=thisContext.getRequestDispatcher("/servlet/Night");
		  myDispatcher.forward(req,resp);//forward
	  }else{
	    
	    
		  
	    out.println("<html><head><title>DispatchServlet</title></head><body>");
		  out.println("<form>");
		  out.println("<br>Hello,Dispatcher include");
		  out.println("</form>");
		  myDispatcher=thisContext.getRequestDispatcher("/servlet/Night1");
	    myDispatcher.include(req,resp);//include
	  }		
	}	
}