sending all frames in a frameset to the same jsp page

hi all

i have this page with framesets ( containing frame1.jsp , frame 2.jsp).

in frame 2.jsp, a submit button will forward from that framset page ( all of the frame) to another jsp page,lets name it otherpage.jsp.

how can i do that?

at the mo, when i click the submit button in frame2.jsp, only the frame2.jsp will go to otherpage.jsp. the frame 1.jsp still remains there...

thanks in advance

[430 byte] By [jazzsa] at [2007-11-27 2:14:58]
# 1

ok,

Ive tried putting this code in otherpage.jsp ;

<script language='javascript'>

if ( top.document.location != window.self.location ) {

top.document.location = "otherpage.jsp";

}

</script>

succesfully get ride of the whole frameset but then, when the otherpage.jsp is loaded, ive lost all the parameters sent by the framesets.

please help....

Message was edited by:

jazzs

jazzsa at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

oopss.. sorry didn't see your post.

you have to submit the page in order to retrieve the data from (frame2.jsp).

document.frm.action = "otherpage.jsp";

document.frm.submit();

hope this helps :)

javascript solution:

function btnSubmit_onClick() {

top.location.href = "otherpage.jsp";

return false;

}

Message was edited by:

sofia320

sofia320a at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
sorry,im a bit comfused there r 2 codes there,could u pls describe which one to put where?
jazzsa at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

frame2.jsp

<html>

<head>

<script language="JavaScript">

function btnSubmit_onClick() {

document.frm.action = "otherpage.jsp";

document.frm.submit();

}

</script>

</head>

<body>

<form name="frm" method="post">

<input type="text" name="txt1">

<input type="text" name="txt2">

<input type="button" name="Submit" onClick="btnSubmit_onClick();">

</form>

</body>

</html>

otherpage.jsp

<%

String txt1 = request.getParameter("txt1");

String txt2 = request.getParameter("txt2");

%>

Message was edited by:

sofia320

sofia320a at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
i ve put the javascript in frame1.jsp ...and the whole frameset did go to otherpage.jspbut still did not get all the parameters from teh frames...
jazzsa at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

actually in frame 2.jsp, ive made a form. and redirect it to a servlet where all the parameters are processed.the servlet then redirect all parameters to anotherpage.jsp. it all went well, except for the anotherpage.jsp is not the top document.

then i made the earlier solution using javascript in anotherpage.jsp . it kinda worked, but then the anotherpage.jsp was called twice.

first : from the servlet with the parameter

second : from the javascript, without any parameter, freshly loaded.

the second comes last, so in the end the anotherpage.jsp didnt retrieve any values.

arggg please help...

jazzsa at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
yeah I get what you mean...it's because your javascript is issuing a GET method, so your parameters will not be retrieved.ok, i'll try to think of a workaround...
sofia320a at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
have you considered using <jsp:include> instead?I also had a lot of problem with frame before, so now I try to avoid it :D
sofia320a at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

no i haven't tried <jsp:include>

i tried to send parameter in the javascript

<script language='javascript'>

if ( top.document.location != window.self.location ) {

top.document.location = "anotherpage.jsp?supplierId=<%=id%>";

}

anotherpage.jsp did become the top document & the id is passed.

but then when i tried to send more than 1 parameter,

anotherpage.jsp did not become the top document.

<script language='javascript'>

if ( top.document.location != window.self.location ) {

top.document.location = "anotherpage.jsp?supplierId=<%=id%>&message=<%=message%>";

}

what went wrong? cant i send more than 1 parameter?

jazzsa at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 10

yeah, i guess this is the only way to pass the request parameters :(

I really don't recommend querystrings... but if it can't really be avoided...

your syntax is correct.

maybe your message is too long. I think querystring can only hold up to 255 characters.

but you should be able to get it, it will only be truncated.

try checking the data if it is correct, check for invalid characters and such.

[code]

<script language='javascript'>

if ( top.document.location != window.self.location ) {

var id = "<%= id %>";

var message = "<%= message %>";

var url = "anotherpage.jsp?id=" + id + "&message=" + message;

// check data

alert( id );

alert( message );

alert( url );

// load it

top.document.location = url;

}

</script>

Message was edited by:

sofia320

Message was edited by:

sofia320

sofia320a at 2007-7-12 2:11:14 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...