pankaj semwal wrote:
 private boolean isUserExist() {
    Connection con = null;
    boolean result = false;

    try {
        con = ConnectionFactory.getConnection();
>
        String sqlQ = "SELECT * FROM USER_MASTER WHERE  LOGIN_ID=?"
                    + "AND PASSWORD=?   AND ROLE=? AND STATUS='Y'";

        PreparedStatement pstmt = con.prepareStatement(sqlQ);
        pstmt.setString(1, getUserId().trim());
        pstmt.setString(2, getPassword().trim());
        pstmt.setString(3, getRole().trim());

        ResultSet rst = pstmt.executeQuery();
        if (rst.next()) {
            user = new User();
            user.setUserId(rst.getInt("USER_ID") == 0 ? 0 : rst
                .getInt("USER_ID"));
            user.setUserName(rst.getString("USER_NAME") == null ? "" : rst
                .getString("USER_NAME"));
            user.setRole(rst.getString("ROLE") == null ? "" : rst
                .getString("ROLE"));
            user.setAddress(rst.getString("LOGIN_ID") == null ? "" : rst
                .getString("LOGIN_ID"));
            user.setCandidateId(rst.getString("CANDIDATE_ID") == null ? ""
                : rst.getString("CANDIDATE_ID"));
>             user.setCustType(getCustType1() == null ? ""
>                 : getCustType1());
            result = true;

            getSession().put("loginDetails",user);*
        }

And in other  Actions i am getting the session as :

User user = (User) getSession().get("loginDetails");
if (user == null) {
    addActionMessage("Not Authorize to view this page.");
    return ERROR;
}

Is there any problem in  this code.

Other than having a bunch of stuff in an action that should be in a service, and some ugly code that should be refactored out, and functionality that should be wrapped in an interceptor, I don't see anything obvious.

Since it's intermittent I'd look first at the session sharing config--it's almost certainly either something to do with that, or something to do with how you're testing (trying from different browser tabs, or different windows in a browser that shares sessions across windows, etc).

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to