KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > olstore > action > LoginAction


1 /**
2  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17  * USA
18  *
19  * Component of: Red Hat Application Server
20  *
21  * Initial Developers: Aizaz Ahmed
22  * Vivek Lakshmanan
23  * Andrew Overholt
24  * Matthew Wringe
25  *
26  */

27 package olstore.action;
28
29 import javax.servlet.http.HttpSession;
30
31 import olstore.form.DemoDynaBaseForm;
32
33 import org.apache.struts.action.ActionForm;
34 import org.apache.struts.action.ActionForward;
35 import org.apache.struts.action.ActionMapping;
36
37  
38 public class LoginAction extends DemoBaseAction{
39
40     public ActionForward execute(ActionMapping mapping,
41                 ActionForm form,
42                 javax.servlet.http.HttpServletRequest request,
43                 javax.servlet.http.HttpServletResponse response)
44                                            throws java.lang.Exception{
45         HttpSession session = request.getSession(false);
46         String username = null;
47         String password = null;
48         session = request.getSession(true);
49         //session.setAttribute("setMySession", new Boolean(true));
50
DemoDynaBaseForm loginForm = (DemoDynaBaseForm) form;
51             username = (String) loginForm.get( "username");
52         password = (String) loginForm.get("password");
53         String path = "/j_security_check?j_username=" +
54                 username + "&j_password=" + password;
55         
56         return new ActionForward(path,true);
57     }
58 }
59  
60
Popular Tags