Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing parameter to a tiles file

Status
Not open for further replies.

donniev

Programmer
Jun 17, 2006
1
US
I have been trying to use a request parameter in an included tiles file (navigation.jsp)

String foo = (String) request.getAttribute("menu_item");


this sets the value correctly the first time the page is his but subsequent calls do not use the new value of the variable.
What am I doing wrong and what is the proper procedure. I am a relative newbie to this so don't worry about insulting me by providing more detail than you think is sufficient. :)
 
Hi

If I understand correctly, you have to put that value on session instead of request.

The action class :
Code:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;

public class MyFairAction extends Action
{
  
  public ActionForward execute(ActionMapping mapping, ActionForm  form,
    HttpServletRequest request, HttpServletResponse response)
    throws Exception
  {
    
    HttpSession theSession=request.getSession();
    theSession.setAttribute("menu_item","whatever you want");
    return mapping.findForward("success");

  }

}
The JSP file :
Code:
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<body>
<bean:write scope="session" name="menu_item"/>
</body>
</html>

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top