By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,179 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,179 IT Pros & Developers. It's quick & easy.

struts <logic:iterate> cannot find collection with IFrames

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
> <iframe src="myAction.do&dispatch=step1" width="100%" height=300

That should be src="myAction.do?dispatch=step1"
Jul 17 '05 #4

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.