struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fzli...@omnytex.com
Subject Re: How to pass a request variable to a frame set
Date Tue, 04 Jan 2005 15:32:12 GMT
There's no way to do it that is Struts-specific, uhh, unless I'm wrong :)

You have to think about what is happening on the browser when PlanAction.java completes and
fowards...

The response is returned to the browser, Offerings.jsp.  This page loads content, Plan.jsp.
 So, as far as the browser is concerned, anything that was passed to the server as part of
Offerings.jsp's response (and request by extenion) is separate from the NEW request for Plan.jsp.
 It's two different requests as far as the browser (and server) is concerned, hence you won't
find anything that was in request scope during the first request it in request scope for the
second request.

There's a couple of ways you could handle this... One is that in Offerings.jsp, where you
specify the source Plan.jsp for the child frame, pass the attribute along with it, something
like this:

<frame name="planFrame" src="/jsp/Plan.jsp?myParam=<%=request.getAttribute("myParam")%>">

Then, in Plan.jsp, you can now access myParam as you would any other parameter.

Another option is to use scripting to get at the variable.  In other words, in Offerings.jsp,
do this in a script block in your header:

<script>
  myParam = "<%=request.getAttribute("myPAram")%>";
</script>

Then, in Plan.jsp, you can do this to get that value:

<script>
  myParam = parent.myParam;
</script>

The first keeps everything in JSP code, the second is client-side.  Depends on which you need
or prefer.  I've done both for various reasons in various cases.

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com

On Tue, January 4, 2005 10:16 am, Krishna Mohan Radhakrishnan said:
> 
> Hi all,
> 
> I have a java clas called PlanAction.java. I am forwarding to a JSP
> called Offerings.jsp.
> But Offerings.jsp contains a frameset  which include another JSP called
> Plan.jsp.
> 
> I need the request attribute set in the PlanAction.java to be available
> in the Plan.jsp.
> I found that request attribute is available in Offerings.jsp but not
> available in Plan.jsp.
> 
> Is there any  method to get the request attribute in Plan.jsp
> 
> 
> 
> Regards,
> Krishna
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


Mime
View raw message