Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

cycle in a jsp

Thread view: 
pincopallo_it@yahoo.it - 11 Oct 2005 14:50 GMT
in a jsp i need to repeat this line
<jsp:useBean id="uv" class="it.finsiel.tea.nhxnwi.util.UserValue"

with different id
as example :
<jsp:useBean id="uv1" class="it.finsiel.tea.nhxnwi.util.UserValue"
<jsp:useBean id="uv2" class="it.finsiel.tea.nhxnwi.util.UserValue"
<jsp:useBean id="uv3" class="it.finsiel.tea.nhxnwi.util.UserValue"

written in this way does not work ....

<%
int m =uv.getId_Ute_Progrn();
for ( int s = m ; s > 0; s--)
                       {%>
<jsp:useBean id="uv
                       <%  out.println(s);%>
" class="it.ibm.teo.ninwi.util.UserFornValue" scope="request"/>

                       <%  }

%>

Getting crazy  over here .... any idea ??
Thanks
Gio
Sikri - 11 Oct 2005 17:11 GMT
My suggestion is to change the approach. "out.println.." will write to
standard out and not to the file or the servlet that is being
generated. That is the line "out.println..." will exist as is in the
servlet and write back to the client.

You want to use indexed properties. Here is an example of using indexed
properties using the standard Struts Tag library.
Steps:
1. Create a bean "UserValueBeanArray" which contains a list of
"UserValue" beans with methods for getUserValue(int index) and
setUserValue(int index, String value).
2. Use the Beanutils package. Struts recognizes this arrangement of
signatures as an "indexed property", in this case with the property
name "UserValue".
3. To refer to a value <!-- indexedtest.jsp -->
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<jsp:useBean id="bean"
class="org.apache.struts.webapp....UserValueBeanArray"/>
<bean:write name="bean" property="UserValue[1]"/>
4. To write a value to the property using dynamic arrays -refer to the
dynamic index section in the following link.
http://struts.apache.org/faqs/indexedprops.html

Hope this helps.
Sikri - 11 Oct 2005 18:01 GMT
My suggestion is to change the approach. "out.println.." will write to
standard out and not to the file or the servlet that is being generated
by the servlet container. That is the line "out.println..." will exist
as is in the servlet and write back to the client.

You want to use indexed properties. Here is an example of using indexed
properties using the standard Struts Tag library.
Steps:
1. Create a bean "UserValueBeanArray" which contains a list of
"UserValue" beans with methods for getUserValue(int index) and
setUserValue(int index, String value).
2. Use the Beanutils package. Struts recognizes this arrangement of
signatures as an "indexed property", in this case with the property
name "UserValue".
3. To refer to a value <!-- indexedtest.jsp -->
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<jsp:useBean id="bean"
class="org.apache.struts.webapp....UserValueBeanArray"/>
<bean:write name="bean" property="UserValue[1]"/>
4. To write a value to the property using dynamic arrays -refer to the
dynamic index section in the following link.
http://struts.apache.org/faqs/indexedprops.html

Hope this helps.
Ross Bamford - 11 Oct 2005 18:09 GMT
> in a jsp i need to repeat this line
> <jsp:useBean id="uv" class="it.finsiel.tea.nhxnwi.util.UserValue"
[quoted text clipped - 22 lines]
> Thanks
> Gio

I'm pretty sure you want to add page context attributes from a scriptlet -  
JSP's aren't recursively parsed.
out.println _is_ the correct way to get output, of course  
(_System_.out.println goes to stdout), but that output doesn't itself get  
compiled and executed, so this won't work.

It's been a while since I did anything JSP but IIRC you want to be getting  
hold of the PageContext (or maybe JspContext?) and calling it's  
setAttribute method. Check the javadoc for either of those as a start...

Signature

Ross Bamford (rosco@roscopeco.remove.co.uk)

Tim B - 12 Oct 2005 06:07 GMT
> in a jsp i need to repeat this line
> <jsp:useBean id="uv" class="it.finsiel.tea.nhxnwi.util.UserValue"
[quoted text clipped - 22 lines]
> Thanks
> Gio

instead of <jsp:useBean id="uv <%  out.println(s);%>" ...

try <jsp:useBean id="uv<%=s%>" ...
or <jsp:useBean id='<%="uv"+ s%>' ...


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.