FileDocCategorySizeDatePackage
UserAction.javaAPI DocExample2176Wed Apr 05 20:04:52 BST 2006com.oreilly.ajax

UserAction

public class UserAction extends org.apache.struts.action.Action

Fields Summary
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

        String username = ((UserForm)form).getUsername();
        HashMap userInfoMap = getUserInfo(username);
        String firstName =(String)userInfoMap.get("firstName");
        String lastName =(String)userInfoMap.get("lastName");
        ((UserForm)form).setFirstName(firstName);
        ((UserForm)form).setLastName(lastName);
        return mapping.findForward("success");
    
private java.util.HashMapgetUserInfo(java.lang.String username)

        
        HashMap hashMap = null;
        Connection con = DatabaseConnector.getConnection();
        try
        {
            Statement statement = con.createStatement();
 
            String sqlString = "select FIRST_NAME,LAST_NAME from USERS where USERNAME ='"+username+"';";
            ResultSet resultSet = statement.executeQuery(sqlString);
            if (resultSet.next())
            {
                hashMap = new HashMap();
                hashMap.put("firstName",resultSet.getString(1));
                hashMap.put("lastName",resultSet.getString(2));
            }
        }
        catch (Exception e)
        {
            System.out.println("exception caught getting usernames");

        }
        finally
        {
            if (con != null)
            {
                try
                {
                    con.close();
                }
                catch (SQLException e)
                {
                }
            }
        }
        return hashMap;