• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in combining <jsp:include> and struts 2.2.1  RSS feed

 
ishan dave
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am facing a problem for combining <jsp:include> and struts 2.2.1. At the time of calling the action of included jsp, we don't want to call the redirect according to included jsp's action.

include_login.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
<table>
<tr>
<td >
<div>
<s:text name="global.hi.message" /> <s:property value="%{#session.userName}"/> 
<s:a action="loginAction" method="doLogout" id="logout"><s:text name="global.logout.name" /></s:a> 
</div>
<div id="login">
<div>
<s:actionerror id="login_err_div" cssStyle="vertical-align: text-bottom;" />
</div>
<div>
<s:textfield name="userName" value="Login"/>
<s:password name="password"/>
<s:submit key="global.loginbutton.name" action="loginAction" method="doLogin"/>
</div>
</div>
</td>
</tr>
</table>


some portion of struts.xml
<action name="loginAction" class="somepackage.LoginAction">
<result name="input">index.jsp</result>
<result name="success">index.jsp</result>
</action>

<action name="searchAction" class="somepackage.SearchAction">
<result name="input">/view/search/searchBox.jsp</result>
<result name="success">/view/search/searchResult.jsp</result>
<result name="detail">/view/search/vehicleDetail.jsp</result>
<result name="loginpopup">/view/user/login.jsp</result>
<result name="error">/view/common/error.jsp</result>
</action>

Now I include this page in other pages like register.jsp, search.jsp, favorites.jsp etc

search.jsp
<html class="cufon-active cufon-ready" xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<body >
<table>
<tr>
<td>
<jsp:include page="/view/common/include_login.jsp"/>
</td>
</tr>
<tr>
<td>
<s:text name="global.searchpage.until.label1"></s:text>  
<select class="w120" name="fromYear" id="fromYear">
<option value="2005" selected="selected">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
</select>
</td>
</tr>
<tr>
<td>
<s:text name="global.searchpage.until.label2"></s:text>  
<select class="w120" name="toYear" id="toYear">
<option value="2005">2005</option>
<option value="2006">2006</option>
<option value="2007">2007</option>
<option value="2008">2008</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011" selected="selected">2011</option>
</select>
</td>
</tr>
<tr>
<td>
<s:submit action="searchAction" method="search" value="Submit"/>
</td>
</tr>
</table>

So the question is when ever we click the Login button from any page it will redirect "input" of loginAction but we don't want to do that, If login is success we want the control of the page should not go out side the page. I mean on successfull login it should call input of searchAction in called from search.jsp, input of registerAction if called from reagister.jsp etc.

for example if a user in search.jsp page and search some data, now he wants to log-in so he provide username and password and when hi clicks the Login button, after login he should able to see the same search.jsp page (with login successfull message). But at present if we click on Login button it will redirect the control to input of loginAction.

In short we want to call the methods and do stuff from the loginAction but don't want to redirect to any other page. So the name of action should be provided dynamically according to the parent page from which login button is clicked.

If any further information is required than please feel free to ask.

Thank you very much for your time and help in advance.

Thank you,
Ishan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!