Frames and request

2005-06-30 Thread Carlos Bracho
Hello.
I am working with frames (I know it's a bad practice... but I cannot do 
anything about it) well the problem is:

I have one jsp file (outter.jsp) which has 2 frames (inner1.jsp and 
inner2.jsp), when I forward to outter.jsp I can see the request's attribute, 
but inner1.jsp and inner2.jsp does not have access to the request's 
attribute, in fact the have a new request and of course that request does 
not have the attribute I set before.

Can I share the request between the frames??? please help me!

-- 
--
Carlos J, Bracho M. 
--
e-mail: [EMAIL PROTECTED]
MSN: [EMAIL PROTECTED]
+58 416 409 21 75 
--


Re: Frames and request

2005-06-30 Thread Frank W. Zammetti
On Thu, June 30, 2005 11:32 am, Carlos Bracho said:
 Hello.
 I am working with frames (I know it's a bad practice... but I cannot do
 anything about it) well the problem is:

Whoever told you using frames is a bad practice was probably scared of
them :)  I find a lot of people see that it takes a little extra effort
and they run away like their hair was on fire.  Using frames is like using
any other technology... if you understand it, and know the pros and cons,
you can do things you could never do otherwise.

But I digress...

 I have one jsp file (outter.jsp) which has 2 frames (inner1.jsp and
 inner2.jsp), when I forward to outter.jsp I can see the request's
 attribute,
 but inner1.jsp and inner2.jsp does not have access to the request's
 attribute, in fact the have a new request and of course that request does
 not have the attribute I set before.

That's right... each frame is a separate request.  You have to think of
them as completely separate browser windows, because thats exactly what
they are.  They just happen to share a session.

There are ways to do what you want... if you are not script-averse, you
can grab the attributes you want from the request associated with
outter.jsp, put them in some Javascript variables, and then access them
from the inner frames using parent.name_of_variable_here (although I've
always used window.top.name_of_frame.name_of_variable, they should both
work).

Alternatively, you can add a query string to the URLs that you populate in
the inner frames from the outer frame, something like:

frameset rows=100,*
  frame name=top
src=top.jsp%=?+(String)request.getAttribute(attr1)%
  frame name=bottom
src=bottom.jsp%=?+(String)request.getAttribute(attr2)%
  /frameset

In the case of the first approach, the attributes are only accessible to
your client-side code, i.e., you can't get at them from within a JSP
scriplet.

The second will allow you to access them in both client-side code and
server-side code.

Frank


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]