Share on Google+Share on Google+

Rahul Shivhare
Struts Login Validation. In This code setter of login page is called only one time again it doesnt call it. Why..?
1 Answer(s)      4 years and 6 months ago
Posted in : Struts

<?xml version="1.0" encoding="UTF-8" ?>

    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />
    <constant name="struts.convention.result.path" value="/pages" />
    <constant name="struts.convention.action.packages" value="com.icici.recon" />
    <constant name="struts.custom.i18n.resources" value="global" />

    <package name="default" extends="struts-default, json-default" namespace="/">
        <action name="index" class="com.credentek.recon.sms.action.IndexAction">

        <action name="indexLogin" class="com.credentek.recon.sms.action.IndexAction" method="login">

        <action name="login" class="com.credentek.recon.sms.action.LoginAction">
            <result >/pages/sms/login.jsp</result>

        <action name="showmenu" class="com.credentek.recon.sms.action.LoginAction" method="showmenu">
            <result name="success">pages/menu/menu.jsp</result>
            <result name="error">pages/menu/blank1.jsp</result>



package com.credentek.recon.sms.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.SessionAware;
import com.credentek.recon.sms.dao.LoginDAO;
import com.credentek.recon.sms.dao.LoginDAOImpl;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport implements SessionAware {

    private static final long serialVersionUID = -8841529855335717596L;

    private final Logger log = Logger.getLogger(LoginAction.class);

    private Map<String, Object> session;
    private String userID;

    private String welcomeDetails;
    private String loginDetails;

    private boolean implementationStatus;

    private String subSystem;

    private LoginDAOImpl loginDAO = new LoginDAOImpl();

    public String execute() {"Loading login page...");"Login page loaded successfully.");

        return SUCCESS;

    public String showmenu() {"showmenu ");
System.out.println("show menu....");
        if(userID.equalsIgnoreCase("") || userID == null){
            System.out.println("no user ID.....");
            return ERROR;
        System.out.println("USER ID.....");
        HttpServletRequest request = (HttpServletRequest) ActionContext
        .getContext().get(ServletActionContext.HTTP_REQUEST); "Validating login information...");

        String dateFormat = loginDAO.getDateFormat();
        if(!"".equals(dateFormat)) {
            session.put("dateFormat", dateFormat);
  "Date Format set to " + dateFormat);
        } else {
            session.put("dateFormat", "dd/MM/yyyy");
            log.error("Date Format is not set properly, please set dateFormat parameter in Parameter table");

        SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); 

        String businessDate =  sdf.format(new Date());

        session.put("userID", userID);
        session.put("userName", userID); 
        session.put("businessDate", "30/04/2012");
        session.put("subSystem", subSystem);
        String moduleID = loginDAO.getModuleDetails(subSystem);"moduleID is set to " + moduleID );    

        session.put("moduleID", moduleID);

        session.put("lastLoginDate", " ");
        session.put("lastBusinessDate", " ");
        session.put("currencyFormat", " ");

        dateFormat = dateFormat.replace("yy", "y");
        dateFormat = dateFormat.replace("E", "D");
        dateFormat = dateFormat.replace("DD", "D");
        if(StringUtils.countMatches(dateFormat, "MMMM") == 1)
            dateFormat = dateFormat.replace("MMMM", "MM");
        else if(StringUtils.countMatches(dateFormat, "MMM") == 1)
            dateFormat = dateFormat.replace("MMM", "M");
        else if(StringUtils.countMatches(dateFormat, "MM") == 1)
            dateFormat = dateFormat.replace("MM", "mm");
        else if(StringUtils.countMatches(dateFormat, "M") == 1)
            dateFormat = dateFormat.replace("M", "m");

        session.put("datePickerFormat", dateFormat);"DatePicker format set to " + dateFormat); "Login successfull. Login Information = " + session);

        welcomeDetails = "Welcome " + userID;

        sdf = new SimpleDateFormat("dd MMMM, yyyy HH:mm:ss z");
        loginDetails = "Current Login : " + sdf.format(new Date());"Login Details: User- " + userID + ", " + loginDetails);

        implementationStatus = true;

        request.getSession().setMaxInactiveInterval(60 * 60); 

        return SUCCESS;

    public void setSession(Map<String, Object> session) {
        this.session = session;

    public String getUserID() {
        return userID;

    public void setUserID(String userID) {
        this.userID = userID;

    public String getWelcomeDetails() {
        return welcomeDetails;

    public void setWelcomeDetails(String welcomeDetails) {
        this.welcomeDetails = welcomeDetails;

    public String getLoginDetails() {
        return loginDetails;

    public void setLoginDetails(String loginDetails) {
        this.loginDetails = loginDetails;

    public boolean isImplementationStatus() {
        return implementationStatus;

    public void setImplementationStatus(boolean implementationStatus) {
        this.implementationStatus = implementationStatus;

    public String getSubSystem() {
        return subSystem;

    public void setSubSystem(String subSystem) {
        this.subSystem = subSystem;



<%@ page language="java" contentType="text/html; charset=ISO-8859-1"

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">


    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="Content-Style-Type" content="text/css" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="cache-control" content="no-cache" />
    <meta http-equiv="expires" content="0" />
    <meta http-equiv="keywords" content="struts2, jquery, jquery-ui, plugin, showcase, jqgrid" />
    <meta http-equiv="description" content="Debit Card Reconciliation System" />

    <link href="styles/layout.css" rel="stylesheet" type="text/css" />

    <link rel="stylesheet" href="styles/styles.css" type="text/css" />  

    <!--[if lte IE 7]>
        <link href="styles/patch_layout.css" rel="stylesheet" type="text/css" />

    <!-- This files are needed for AJAX Validation of XHTML Forms -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/struts/utils.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/struts/xhtml/validation.js"></script>

    <script type="text/javascript" src="js/jquery.js"></script>

    <sj:head debug="true" compressed="false" jquerytheme="humanity" loadFromGoogle="false" ajaxhistory="false" defaultIndicator="myDefaultIndicator" defaultLoadingText="Please wait ..."/>

    <!-- This file includes necessary functions/topics for validation and all topic examples -->
    <script type="text/javascript" src="js/showcase.js"></script>
    <script type="text/javascript" src="js/common.js"></script>
    <script type="text/javascript" src="js/right.js"></script>
    <script type="text/javascript" src="js/date.js"></script>

    <script type="text/javascript" src="js/ui/jquery.ui.datepicker.js"></script>
    <script type="text/javascript" src="js/jquery.tablesorter.js"></script>
    <script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>
    <script type="text/javascript" src="js/jquery.tablesorter.filter.js"></script>
    <script type="text/javascript" src="js/ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="js/ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="js/ui/jquery.ui.mouse.js"></script>

    <div class="page_margins">
        <div class="page">
            <table width="100%" border="0" class="ui-widget-header">
                <td width="40%"><div id="headline">
                    <h1 class="ui-state-default" style="background: none; border: none;">Login Attempt </h1>
                    <h4 class="ui-state-default" style="background: none; border: none;">Login  <i><small>Login</small></i></h4>
                    <img id="myDefaultIndicator" src="images/ajax-loader.gif" alt="Loading..." style="display:none"/>
                <td width="30%"><div id="subSystemInfo" class="ui-state-default" style="background: none; border: none;font-size: 20px;"></div> </td>

                <td width="30%">
            <div >
                <div style="float: right;">                 
                    <s:form id="themeform" action="setlocale" theme="simple">
                        <div id="languageBox">


                        <sj:submit id="submitForm" formIds="themeform" listenTopics="formTopic" cssStyle="display: none;" />


                    <div class="ui-state-default" style="background: none; border: none; padding-top: 3px; padding-bottom: 3px; float: right;"><span id="userInfo"></span><span><a id="logout" href="index.action"></a></span></div><br>

                    <div id="loginInfo" class="ui-state-default" style="background: none; border: none;float: right;"></div>



            <div id="menu"></div>

            <s:url id="urlLogin" action="login" />
            <sj:div id="main" href="%{urlLogin}" cssStyle="height:320px">
                <img id="indicator" src="images/indicator.gif" alt="Loading..." />

            <!-- begin: #footer -->
            <div id="footer">
                Copyright &copy; 2012, CredenTek Software &amp; Consultancy Private Limited. <a href="" target="_blank"></a>

    <div class="curtain" id="loading-filter" style="display:none; height: 850px;">
        <div style="margin-top: 200px; text-align: center;">  
            <img src='images/loading.gif' width='110' height='90' alt='loading ...'/>


<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>

<div id="col3" align="center" style="width: 100%;">
    <div id="col3_content" align="center" class="clearfix" style="width: 90%;">
        <s:url id="urlShowMenu" action="showmenu"/>
        <%-- <sj:a id="loginLink">Login</sj:a> --%>

        <table cellpadding="0" cellspacing="7"  border="0" width="100%">
            <tr valign="top">
                <td width="35%"><img src="images/icicibank.jpg" width="250px"></td>
                <td  width="35%" align="right">
                    <h4 class="ui-state-default" style="background: none; border: none;">Login</h4>


                    <s:form id="loginForm" theme="simple">
                    <table cellpadding="0" cellspacing="15" border="3" width="100%" >

                        <tr style="border:0px;">
                            <td width="50%" style="border:0px;" align="left">User Name </td>
                            <td width="50%" style="border:0px;">
                                <s:textfield id="userID" cssClass="searchInputText" name="userID"></s:textfield>
                        <tr style="border:0px;">
                            <td style="border:0px;" align="left">Password </td>
                            <td style="border:0px;"><s:password id="password" cssClass="searchInputText" /></td>
                        <tr style="border:0px;">
                            <td style="border:0px;" align="left">Sub-System</td>
                            <td style="border:0px;"><s:select name="subSystem" list="{'Nostro','CMS'}" cssStyle="width:132px" cssClass="searchInputText"/></td>

                        <tr align="right" style="border:0px;">
                            <td align="right" colspan="2" style="border:0px;">
                                <sj:submit id="loginBtn" name="Logn" href="%{urlShowMenu}" targets="menu" button="true"></sj:submit>    




    <!-- IE Column Clearing -->
    <div id="ie_clearing">&#160;</div>

<script type="text/javascript">

    $(document).ready(function() {






Java Spring Hibernate Struts Training Dynamic tabs in struts 1.2 Unable to upload a file to mysql database using struts1 Pagination in struts 2 struts2 filterdispatcher is deprecated please use the new filters viewing How to add struts2 dependency in Maven? Struts Exception Handling can you check below code if any erors multimedia how to display the value of termcell name in label class not found exception Where to learn Struts 2? dropdown cacheing Upload and Download Large files in jsp What is Struts 2 framework struts and hibernate based health care project source code struts and hibernate based health care project source code Struts 2 Integration with Struts 1 About captcha of strut2 About captcha of strut2 Which is the good website for struts 2 tutorials? advance java source code source code In Struts 2 how to pass the Struts struts internationalization for Korean language struts2 Struts2 and Hibernate Fetch Data Base Value Struts2 and Hibernate Fetch Data Base Value Struts2 and Hibernate i want to create an application with only a button which on click displays table from database using struts2 and hibernate on eclipse Struts2 and Hibernate Struts2 and Hibernate Struts2 validation Procedure Struts2 validation Procedure Struts2 validation Procedure Struts2 validation Procedure Struts 2 action-validation.xml not loading Struts-2 and Ajax integration STRUTS QUESTION conerting web project into .exe file About Select tag ScartApplication aplicacion ecommerce struts 1.3 struts 1.3 sms prob Need to know struts1 all jar file names struts with hibernate


Advertisement null