1 PackageSanglp.servlet;2 3 Importjavax.servlet.*;4 ImportJavax.servlet.annotation.WebListener;5 Importjavax.servlet.http.HttpServletRequest;6 7 /**8 * Created by Administrator on 2016/10/5.9 */Ten @WebListener One Public classRequestlistenerImplementsServletrequestlistener,servletrequestattributelistener { A - //the end of the user request, the method is triggered when initialized - @Override the Public voidrequestinitialized (servletrequestevent servletrequestevent) { -HttpServletRequest request=(HttpServletRequest) servletrequestevent.getservletrequest (); -System.out.println ("Send To" +request.getrequesturi () + "request Initialized"); - } + //The method is triggered when the user requests the end and is destroyed - @Override + Public voidrequestdestroyed (servletrequestevent servletrequestevent) { AHttpServletRequest request=(HttpServletRequest) servletrequestevent.getservletrequest (); atSystem.out.println ("Send To" +request.getrequesturi () + "request destroyed"); - - } - - @Override - Public voidattributeadded (servletrequestattributeevent servletrequestattributeevent) { inServletContext application=Servletrequestattributeevent.getservletcontext (); - //get the added property name and property value toString name=servletrequestattributeevent.getname (); +Object value=Servletrequestattributeevent.getvalue (); -System.out.println (application+ "range added" +name+ "value for" +value+ "property"); the * } $ Panax Notoginseng @Override - Public voidattributeremoved (servletrequestattributeevent servletrequestattributeevent) { theServletContext application=Servletrequestattributeevent.getservletcontext (); + //get the added property name and property value AString name=servletrequestattributeevent.getname (); theObject value=Servletrequestattributeevent.getvalue (); +System.out.println (application+ ") has removed the attribute" +name+ "with the value" +value+ "); - } $ $ @Override - Public voidattributereplaced (servletrequestattributeevent servletrequestattributeevent) { -ServletContext application=Servletrequestattributeevent.getservletcontext (); the //get the added property name and property value -String name=servletrequestattributeevent.getname ();WuyiObject value=Servletrequestattributeevent.getvalue (); theSystem.out.println (application+ "Scope" replaced the "+name+" value for the "+value+" property "); - } Wu}
"Java EE Enterprise Application Combat Learning record" Requestlistener