1 16 17 package examples.app3; 18 19 import java.io.IOException ; 20 import java.util.Hashtable ; 21 import java.util.Locale ; 22 import javax.servlet.RequestDispatcher ; 23 import javax.servlet.ServletException ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpSession ; 26 import javax.servlet.http.HttpServletResponse ; 27 import org.apache.struts.action.Action; 28 import org.apache.struts.action.ActionError; 29 import org.apache.struts.action.ActionErrors; 30 import org.apache.struts.action.ActionForm; 31 import org.apache.struts.action.ActionForward; 32 import org.apache.struts.action.ActionMapping; 33 import org.apache.struts.action.ActionServlet; 34 import org.apache.struts.util.MessageResources; 35 36 37 44 45 public final class LogonAction extends Action 46 { 47 48 49 51 63 public ActionForward execute(ActionMapping mapping, 64 ActionForm form, 65 HttpServletRequest request, 66 HttpServletResponse response) 67 throws IOException , ServletException 68 { 69 70 String username = ((LogonForm) form).getUsername(); 71 String password = ((LogonForm) form).getPassword(); 72 73 HttpSession session = request.getSession(); 76 session.setAttribute(Constants.USER_KEY, form); 77 78 StringBuffer message = new StringBuffer ("LogonAction: User '"); 80 message.append(username); 81 message.append("' logged on in session "); 82 message.append(session.getId()); 83 servlet.log(message.toString()); 84 85 return (mapping.findForward(Constants.CONTINUE)); 88 89 } 90 91 } 92 | Popular Tags |