import java.lang.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class ContextServlet extends HttpServlet{
	String defaultGreeting;
	public void init(ServletConfig config) throws ServletException{
		super.init(config);			
	}
	
	public void doGet(HttpServletRequest req,HttpServletResponse resp)
					throws IOException,ServletException{
		ServletContext thisContext=getServletConfig().getServletContext();
		thisContext.setAttribute("MyName","zhanghz");
		String myname=(String)thisContext.getAttribute("MyName");
		
		resp.setContentType("text/html");
		PrintWriter out=resp.getWriter();
		
		out.println("<html><head><title>ContextServlet</title></head><body>");
		out.println("<br>MyName="+myname);
		
		out.println("</body></html>");
	}	
}