2

The question is a bit long but i feel its interesting. Kindly have a look plz. I have a jsp called "Menubaruser.jsp" as follows:

<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
    <div id='cssmenu'>
            <ul>
                <s:url  id="userhome" value="/login.action?login.username=%{#session.username}&login.password=%{#session.password}"></s:url>
                <li><sj:a id="user_home" href="%{userhome}" targets="mainContent"><span>Home</span></sj:a></li>
                <%-- <li><s:a action="#"><span>Home</span></s:a></li> --%>

                <s:url  id="showProfile" value="/profile.action"></s:url>
                <li><sj:a id="profile_show" href="%{showProfile}" targets="mainContent"><span>Show Profile</span></sj:a></li>

                <s:url  id="editProfile" value="/editProfileLink.action"></s:url>
                <li><sj:a id="profile_edit" href="%{editProfile}" targets="mainContent"><span>Update Profile</span></sj:a></li>

                <s:url  id="signout" value="/logout.action"></s:url>
                <li><sj:a id="signout" href="%{signout}" targets="mainContent"><span>Sign Out</span></sj:a></li>
                <%-- <li class='last'><s:a action="#"><span>Contact Us</span></s:a></li> --%>
            </ul>
    </div>

What actually happens is, when a user log in, username and password are set as session variables with their values. Now user can do whatever he wishes like update profile, show profile etc. Now what i want is when user click on home then the home page of user must appear i.e. the page that appears when user logs in. That page is named as loginSuccess.jsp and it is opened corresponding to login.action as shown in following struts.xml:

 <action name="login" class="com.view.LoginAction" method="checkLogin">
        <result name="input">/loginPage.jsp</result>
        <result name="loginSuccessUser" type="chain">userHistory</result>
        <result name="loginSuccessAdmin">/loginSuccessAdmin.jsp</result>
        <result name="loginClicked">/loginPage.jsp</result>
    </action>
    <action name="userHistory" class="com.view.HistoryAction" method="UserHistory">
            <result name="showHistory">/loginSuccess.jsp</result>
    </action>

loginSuccess.jsp contains some dynamic content that comes through userhistory action. What i wish is that content is also loaded when home is clicked. Now whats happening is when user click home, then action login.action is called with the querystring sent by me corresponding to click as shown in "menubaruser.jsp" but the o/p shown is that it is not loading the password field. It returns "input" that shows me server side validation error for password as "Password is required".

The desired jsp to be rendered is named loginSuccess.jsp and is coded as follows:

<%@ taglib prefix="s" uri="/struts-tags"%>
       <jsp:include page="menubaruser.jsp"></jsp:include>
       <div style="width:898px"><br><center>Welcome Mr. <b><s:property value="#session.name"/> </b></center> </div> 
       <div id="ajaxdiv">
        <div id="ContentLeft">
            <jsp:include page="search.jsp"></jsp:include>
        </div>
        <div id="contentRight">
            <jsp:include page="topdeals.jsp"></jsp:include>
        </div>
       </div>
        <br>
        <div>
            <jsp:include page="userHistoryWidget.jsp"></jsp:include>
        </div>    

UserHistoryWidget.jsp is as follows:

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

    <div id="searchHeaderHistory">Booking History</div>
    <div class="CSSTableGenerator">
        <table>
            <colgroup>
                <col span="1" style="width: 5%;">
                <col span="1" style="width: 10%;">
                <col span="1" style="width: 8%;">
                <col span="1" style="width: 15%;">
                <col span="1" style="width: 15%;">
                <col span="1" style="width: 6%;">
                <col span="1" style="width: 6%;">
                <col span="1" style="width: 17%;">
                <col span="1" style="width: 18%;">
            </colgroup>

            <tr>
                <td>Ticket ID</td>
                <td>Booking Date</td>
                <td>Flight ID</td>
                <td>From</td>
                <td>To</td>
                <td>Total Fare</td>
                <td>Net Fare</td>
                <td></td>
                <td></td>
            </tr>

            <s:iterator value="ticketsList" var="ticket" status="stat">

                <tr>
                    <td align="center"><s:property value="#ticket.tid" /></td>
                    <td align="center"><s:property value="#ticket.bookingdate" /></td>
                    <td align="center"><s:property
                            value="#ticket.scheduleDetails.flightDetails.fid" /></td>

                    <s:if test="#ticket.flag==3">
                        <td><s:property
                                value="#ticket.scheduleDetails.flightDetails.routeDetails.via" /><br>
                            <s:property value="#ticket.scheduleDetails.via_dep_date" />&nbsp;<s:property
                                value="#ticket.scheduleDetails.via_dep_time" />hrs</td>
                    </s:if>
                    <s:if test="#ticket.flag==1 ||#ticket.flag==2||#ticket.flag==4">
                        <td><s:property
                                value="#ticket.scheduleDetails.flightDetails.routeDetails.source" /><br>
                            <s:property value="#ticket.scheduleDetails.source_dep_date" />&nbsp;<s:property
                                value="#ticket.scheduleDetails.source_dep_time" />hrs</td>
                    </s:if>
                    <s:if test="#ticket.flag==1 ||#ticket.flag==2||#ticket.flag==3">
                        <td><s:property
                                value="#ticket.scheduleDetails.flightDetails.routeDetails.destination" /><br>
                            <s:property value="#ticket.scheduleDetails.dest_arr_date" />&nbsp;<s:property
                                value="#ticket.scheduleDetails.dest_arr_time" />hrs</td>
                    </s:if>
                    <s:if test="#ticket.flag==4">
                        <td><s:property
                                value="#ticket.scheduleDetails.flightDetails.routeDetails.via" /><br>
                            <s:property value="#ticket.scheduleDetails.via_arr_date" />&nbsp;<s:property
                                value="#ticket.scheduleDetails.via_arr_time" />hrs</td>
                    </s:if>
                    <td align="center"><s:property value="#ticket.fare" /></td>
                    <td align="center"><s:property value="#ticket.dealFare" /></td>
                    <td style="width: 150px" align="center">
                        <s:url  id="getPassengers" value="/getPassengers.action">
                            <s:param name="Tid" value="#ticket.tid" />
                        </s:url>
                         <sj:a id="link_%{#stat.index}" href="%{getPassengers}" targets="ajaxdiv" cssClass="orangebuttonsmall">
                                View Details    
                         </sj:a>
                    </td>
                    <td style="width: 150px" align="center">
                        <s:a action="cancel" id="button1" style="float:left" cssClass="orangebuttonsmall">Cancel Ticket
                             <s:param name="Tid" value="#ticket.tid"></s:param>
                        </s:a>
                    </td>
                </tr>
            </s:iterator>

        </table>
    </div>

Now what i wish is whenever this loginSuccess.jsp opens the userHIstoryWidget.jsp content is loaded. So When i click Home in menubaruser.jsp, i want the "login" to be called with value of username and password to be set with values present in session. If this happens successfully then due to action chaining , the "userhistory" action gets called and displays loginSuccess.jsp with required data.

Problem is that when i send the query string with value of username and password, it doesn't set the value of password and it takes password as empty and hence return "input" which renders loginPage.jsp with actionerror "Password empty". I also tried sending a constant value instead of session value in password, but still the problem persist. It set the value of username but fails for password.

LoginPage.jsp is as follows:

<%@ taglib prefix="s" uri="/struts-tags"%>
            <%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
            <jsp:include page="menubar.jsp"></jsp:include>
            <br><br><br><br><br><br>              
            <s:form action="login" method="post" theme="css_xhtml" cssClass="form1" style="margin:0 211px">
                <div class="searchHeader">LOGIN</div>
                <div id="error">
                    <s:property value="errormsg"/>
                </div>
                <s:textfield label="Username" name="login.username" />
                <s:textfield label="Password" name="login.password" />
                <div class="submitButton">
                    <sj:submit value="SUBMIT" targets="mainContent"/>
                </div>
            </s:form>

Kindly help ...

Gaurav Kumar
  • 1,091
  • 13
  • 31
  • Add `escapeAmp="false"` to ``. – Aleksandr M Oct 14 '13 at 08:25
  • @AleksandrM nothing happens sir.. The same error occurs. It is not replacing the value of password field by what i pass in querystring. Even if i pass a constant value in it,it doesn't take it. The password attribute is left empty no matter what and hence input is returned. – Gaurav Kumar Oct 14 '13 at 08:29
  • Show the rendered HTML. – Dave Newton Oct 14 '13 at 15:11
  • @DaveNewton I have added the jsps . Please check. And thanks for reply. I was actually waiting for an answer from you. Hope u help me with this. :) – Gaurav Kumar Oct 14 '13 at 16:48
  • Use `` to put parameters into `` tag. Try with simple link, is it working or not? – Aleksandr M Oct 15 '13 at 07:51
  • Maybe something in your "chain" is dropping `password` named fields. Could you try to change it to `haxxword` ? If instead you have already solved it, consider answering yourself here explaining how. – Andrea Ligios Oct 31 '13 at 10:57
  • @andreaLigios i couldn't solve it .. I applied some othe rlogic to serve my purpose.. – Gaurav Kumar Oct 31 '13 at 11:11
  • I was curious. If the other fields was populating correctly in the same page, and only the password was not, then probably this was name-related. If you will have the chance, try that :> – Andrea Ligios Oct 31 '13 at 11:17
  • @AndreaLigios i already tried a lot of things. Name was fine. I think since it is a "Password" field so it doesnt populate it for security purposes or anything like that.. Just a thought, it is.. Dont know the actual reason.. – Gaurav Kumar Nov 01 '13 at 05:56

1 Answers1

0

As per my understanding from the above post you are trying to set value attribute to the password type .

This is not possible due to some security concerns.

you can use text box and use some java script code to change the visibility of the chars displayed in the input type.

satyam.kudikala
  • 101
  • 1
  • 1
  • 5