import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionServlet;
public class UitActionServlet extends ActionServlet {
private Servlet servlet;
/* (non-Javadoc)
* @see org.apache.struts.action.ActionServlet#process(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
@Override
protected void process(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
// TODO Auto-generated method stub
boolean result = false;
HttpSession session = request.getSession();
User user = (User)session.getAttribute(Constants.USER_KEY);
List exceptionPath = new ArrayList(); //세션이 없어도 접근가능한 Action 리스트
exceptionPath.add("/1.do");
exceptionPath.add("/2.do");
exceptionPath.add("/3.do");
exceptionPath.add("/4.do");
if ( user != null ){
result = true;
}else{
for(int i = 0; i < exceptionPath.size(); i++){
if(request.getServletPath().equals(exceptionPath.get(i))){
result = true;
}
}
}
System.out.println("UitActionServlet\n ServletPath = " + request.getServletPath() +
"\nrequest permit is " + result);
if(!result){
//"javax.servlet.include.servlet_path" 의 경우 struts 에서 Action연결 시 적용되지만, get으로 로그를 찍어도 나오지 않음;;
request.setAttribute("javax.servlet.include.servlet_path","/refuse"); //refuse Action으로 변경
}
super.process(request, response);
}
}