package example_lg_part_1;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class ThirdFilter extends HttpServlet implements Filter 
{
    private FilterConfig filterConfig;
    public void init(FilterConfig filterConfig) throws ServletException
    {
        this.filterConfig = filterConfig;
    }
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain)
    {
        HttpSession ses = ((HttpServletRequest) request).getSession(true);
        ses.setAttribute("ServerName", request.getServerName());
        ses.setAttribute("RemoteAddr", request.getRemoteAddr());
        String username = request.getParameter("username");
        ses.setAttribute("username", username);
        try {
            filterChain.doFilter(request, response);
           } 
catch (ServletException sx) 
{ filterConfig.getServletContext().log(sx.getMessage());}
         catch (IOException iox) 
{   filterConfig.getServletContext().log(iox.getMessage());}
    }
    public void destroy() 
    { }
}
