472,799 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,799 software developers and data experts.

struts <logic:iterate> cannot find collection with IFrames

nc
My iterator can find my collection when my Action class calls my jsp
directly, however when my Action class calls an html file that is set
up with IFrames (one of which is loading that same jsp), I get a
servlet error "cannot find collection".

Not usre if my issue is HTML, JSP, WebSphere or ???
Any help is very much appreciated.

HTML file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> </TITLE>
<META HTTP-EQUIV="Expires" CONTENT="Mon, 03 Mar 1997 01:00:00 GMT">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</HEAD>
<BODY>
<table width="700" border="1" cellspacing="0" cellpadding="0">

<tr><td>
<iframe src="myJSP.jsp" width="100%" height=300 align="left"
scrolling="yes" NORESIZE
marginwidth="10" marginheight="0" name="step1">
</iframe>
</td></tr>

<tr><td>
<iframe src="" width="100%" height=400 align="left" scrolling="yes"
NORESIZE
marginwidth="10" marginheight="0" name="step2">
</iframe>
</td></tr>

</table>
</BODY>
</HTML>

JSP file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tlds/amarda-logic.tld" prefix="ifLogic"%>

<html>
<head>
<title> </title>

<META name="GENERATOR" content="IBM WebSphere Studio">

<SCRIPT LANGUAGE="JavaScript">
<!--
inSubmit=0;
function doSubmit() {
if( inSubmit == 0 ) {
inSubmit = 1;
return true;
}
return false;
}
// -->
</SCRIPT>

</head>
<body bgcolor="#ffffff" link="#000000" alink="#000000"
vlink="#000000">
<jsp:useBean id="viewBean"
class="myClass"
scope="request" />
<form name="form" method="post" action="myJSP2.jsp" target="step2"
onSubmit="return doSubmit();">
<input type="hidden" name="validateKey" value="1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<logic:iterate id="id_Element" name="viewBean" property="myElement"
scope="request">

<tr>
<td colspan="1">&nbsp;</td>

<td colspan="2" align="left"><input type="radio" name="inputValue"
value="<bean:write name="id_Element" property="myProperty" />"
onClick="document.form.submit()"></td>

<td colspan="1">&nbsp;</td>

</tr>

</logic:iterate>
</TABLE>
</TD></TR>

</table>
</form>

</body>
</html>
Jul 17 '05 #1
4 10222
This can't work. The problem is that the HTML goes to the browser, and the
browser then makes a separate request to the server. In the context of the
new request, your collection doesn't exist.

Since I don't know enough about your app, I'm not sure if this solution will
work, but:

1) In your original action, put the collection in session scope instead of
request scope (you possibly have issues here about clearing old data on
later requests)

Some recommendations on improving the code:

1) Make the iframe reference a new action (or use a dispatch action)--when
using struts, it's a good habit to make all requests go through the struts
controller.
2) Change direct references to jsp's or actions into references to global
forwards using the struts tag library--This allows flexibility in your app
and makes sure all links go through the rewriter.

Hope this helps

"nc" <nc**********@hotmail.com> wrote in message
news:16*************************@posting.google.co m...
My iterator can find my collection when my Action class calls my jsp
directly, however when my Action class calls an html file that is set
up with IFrames (one of which is loading that same jsp), I get a
servlet error "cannot find collection".

Not usre if my issue is HTML, JSP, WebSphere or ???
Any help is very much appreciated.

HTML file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> </TITLE>
<META HTTP-EQUIV="Expires" CONTENT="Mon, 03 Mar 1997 01:00:00 GMT">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</HEAD>
<BODY>
<table width="700" border="1" cellspacing="0" cellpadding="0">

<tr><td>
<iframe src="myJSP.jsp" width="100%" height=300 align="left"
scrolling="yes" NORESIZE
marginwidth="10" marginheight="0" name="step1">
</iframe>
</td></tr>

<tr><td>
<iframe src="" width="100%" height=400 align="left" scrolling="yes"
NORESIZE
marginwidth="10" marginheight="0" name="step2">
</iframe>
</td></tr>

</table>
</BODY>
</HTML>

JSP file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tlds/amarda-logic.tld" prefix="ifLogic"%>

<html>
<head>
<title> </title>

<META name="GENERATOR" content="IBM WebSphere Studio">

<SCRIPT LANGUAGE="JavaScript">
<!--
inSubmit=0;
function doSubmit() {
if( inSubmit == 0 ) {
inSubmit = 1;
return true;
}
return false;
}
// -->
</SCRIPT>

</head>
<body bgcolor="#ffffff" link="#000000" alink="#000000"
vlink="#000000">
<jsp:useBean id="viewBean"
class="myClass"
scope="request" />
<form name="form" method="post" action="myJSP2.jsp" target="step2"
onSubmit="return doSubmit();">
<input type="hidden" name="validateKey" value="1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<logic:iterate id="id_Element" name="viewBean" property="myElement"
scope="request">

<tr>
<td colspan="1">&nbsp;</td>

<td colspan="2" align="left"><input type="radio" name="inputValue"
value="<bean:write name="id_Element" property="myProperty" />"
onClick="document.form.submit()"></td>

<td colspan="1">&nbsp;</td>

</tr>

</logic:iterate>
</TABLE>
</TD></TR>

</table>
</form>

</body>
</html>

Jul 17 '05 #2
nc
Thank you, Java Architect

I like DispatchAction, I'm going with that. However, I cannot seem to
have the action recognize the dispatch parameter(step1), the iframe
src returns to the DispatchAction execute method, not the step1 method
I've coded. new HTML follows.

Thanks again for any help

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> </TITLE>
<META HTTP-EQUIV="Expires" CONTENT="Mon, 03 Mar 1997 01:00:00 GMT">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</HEAD>
<BODY>
<table width="700" border="1" cellspacing="0" cellpadding="0">

<tr><td colspan="1"><IMG SRC="images/spacer.gif" WIDTH=400 HEIGHT=5
BORDER=0 ALT=""></td></tr>

<tr><td>
<iframe src="myAction.do&dispatch=step1" width="100%" height=300
align="left" scrolling="yes" NORESIZE
marginwidth="10" marginheight="0" name="step1">
</iframe>
</td></tr>

<tr><td>
<iframe src = "" width="100%" height=300 align="left" scrolling="yes"
NORESIZE
marginwidth="10" marginheight="0" name="step2">
</iframe>
</td></tr>

<tr><td colspan="1"><IMG SRC="images/spacer.gif" WIDTH=400 HEIGHT=5
BORDER=0 ALT=""></td></tr>

</table>
</BODY>
</HTML>
"Java Architect" <da**@dynamicresolve.com> wrote in message news:<sd********************@adelphia.com>...
This can't work. The problem is that the HTML goes to the browser, and the
browser then makes a separate request to the server. In the context of the
new request, your collection doesn't exist.

Since I don't know enough about your app, I'm not sure if this solution will
work, but:

1) In your original action, put the collection in session scope instead of
request scope (you possibly have issues here about clearing old data on
later requests)

Some recommendations on improving the code:

1) Make the iframe reference a new action (or use a dispatch action)--when
using struts, it's a good habit to make all requests go through the struts
controller.
2) Change direct references to jsp's or actions into references to global
forwards using the struts tag library--This allows flexibility in your app
and makes sure all links go through the rewriter.

Hope this helps

"nc" <nc**********@hotmail.com> wrote in message
news:16*************************@posting.google.co m...
My iterator can find my collection when my Action class calls my jsp
directly, however when my Action class calls an html file that is set
up with IFrames (one of which is loading that same jsp), I get a
servlet error "cannot find collection".

Not usre if my issue is HTML, JSP, WebSphere or ???
Any help is very much appreciated.

HTML file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE> </TITLE>
<META HTTP-EQUIV="Expires" CONTENT="Mon, 03 Mar 1997 01:00:00 GMT">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
</HEAD>
<BODY>
<table width="700" border="1" cellspacing="0" cellpadding="0">

<tr><td>
<iframe src="myJSP.jsp" width="100%" height=300 align="left"
scrolling="yes" NORESIZE
marginwidth="10" marginheight="0" name="step1">
</iframe>
</td></tr>

<tr><td>
<iframe src="" width="100%" height=400 align="left" scrolling="yes"
NORESIZE
marginwidth="10" marginheight="0" name="step2">
</iframe>
</td></tr>

</table>
</BODY>
</HTML>

JSP file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/tlds/amarda-logic.tld" prefix="ifLogic"%>

<html>
<head>
<title> </title>

<META name="GENERATOR" content="IBM WebSphere Studio">

<SCRIPT LANGUAGE="JavaScript">
<!--
inSubmit=0;
function doSubmit() {
if( inSubmit == 0 ) {
inSubmit = 1;
return true;
}

return false;
}
// -->
</SCRIPT>

</head>
<body bgcolor="#ffffff" link="#000000" alink="#000000"
vlink="#000000">
<jsp:useBean id="viewBean"
class="myClass"
scope="request" />
<form name="form" method="post" action="myJSP2.jsp" target="step2"
onSubmit="return doSubmit();">
<input type="hidden" name="validateKey" value="1">
<table width="100%" border="0" cellspacing="0" cellpadding="0">

<logic:iterate id="id_Element" name="viewBean" property="myElement"
scope="request">

<tr>
<td colspan="1">&nbsp;</td>

<td colspan="2" align="left"><input type="radio" name="inputValue"
value="<bean:write name="id_Element" property="myProperty" />"
onClick="document.form.submit()"></td>

<td colspan="1">&nbsp;</td>

</tr>

</logic:iterate>
</TABLE>
</TD></TR>

</table>
</form>

</body>
</html>

Jul 17 '05 #3
> <iframe src="myAction.do&dispatch=step1" width="100%" height=300

That should be src="myAction.do?dispatch=step1"
Jul 17 '05 #4
nc
Thanks Murray and Java Architect -
You guys are the best.
Dumb mistake of mine.

"Murray" <pa***@SPAMOFFoptusnet.SPAMMAGE.com.au> wrote in message news:<40***********************@news.optusnet.com. au>...
<iframe src="myAction.do&dispatch=step1" width="100%" height=300


That should be src="myAction.do?dispatch=step1"

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Russ Perry Jr | last post by:
I'm using "ID" and "Value" in the generic sense here... Let's say one page I had a <html:select> with a collection like this: <html:options collection="items" property="key"...
3
by: vijay | last post by:
Hi, I am using struts frame work and in one of the jsp pages I have a bunch of IFRAMES like this.(This is in logic iterate and the recordId is incremented with that iteration)...
5
by: Alex Maghen | last post by:
I frequently find myself wanting to insert some basic client-side JavaScript functions in the page of an ASPX of mine. But I find it so frustrating that I have to actually contruct my JavaScript in...
13
by: rakeshvthu | last post by:
hi all, i am using window.onunload() method in IE6, it works fines in local, but it does not work in Integration Box(Linux Environment), i have written a simple alert() statement to check whether...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.