LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   about Jakarta Struts, Jsp's and Tomcat.... problem iterating in a jsp (https://www.linuxquestions.org/questions/programming-9/about-jakarta-struts-jsps-and-tomcat-problem-iterating-in-a-jsp-254945/)

poeta_boy 11-14-2004 11:49 PM

about Jakarta Struts, Jsp's and Tomcat.... problem iterating in a jsp
 
Hello:

I am building a little web application under struts and tomcat. I have managed to understand the things on web.xml and struts-config.xml.

I also have a login screen so the user is authenticated.... the jsp would create a LoginAction populated by a LoginForm, go to the business delegate and check the database for authentication, in order to forward the user to the next page...

So bassically I can use the interaction between a form in html (jsp) to fill an ActionForm and trigger an Action in the serverside..... But I have trouble in doing the same thing without the form in html (jsp)

The thing is that once the user is logged int, there should be an screen with some info about him/her.... let's say, some news generated by the system.

I've googled for it but I believe it's quite too specific so I can't find the answer... I also believe it should be something quite simple, as a single line or something... I hope :)

I've reading the ORelly Programming with Jakarta Struts but I couldn't figure it out :( please anyone be so kind to help me


I think about those news as an array of objects wrapping just an String with the content of the new.

So I have in the login Action in struts-config.xml the following mapping:

Code:

<action
    path="/login"
    type="crimson.ccss.common.login.LoginAction"
    scope="request"
    name="loginForm"
    validate="true"
    input="/login.jsp">
    <forward name="Success" path="/action/teacher/getWelcomeInformation" redirect="true"/>
    <forward name="Failure" path="/login.jsp" redirect="true"/>
  </action>

and as forward success:

Code:

<action
    path="/teacher/getWelcomeInformation"
    type="crimson.ccss.teacher.action.GetWelcomeInformationAction"
    scope="request"
    name="getWelcomeInformationForm"
    validate="false">
    <forward name="Success" path="/teacher/welcome.jsp"/>
  </action>

the bean correspondant to it is a dynaform:

Code:

  <form-bean
              name="getWelcomeInformationForm"
        dynamic="true"
        type="org.apache.struts.action.DynaActionForm">
    <form-property name="news" type="java.util.ArrayList"/>
    <form-property name="subjects" type="java.util.ArrayList"/>
    </form-bean>

I've managed to get the GetWelcomeInformationAction check the database and retrieve the data of "news" and "subjects" and set it to the dynaform:

inside GetWelcomeInformationAction.execute():

Code:

                  ((DynaActionForm)form).set( "news", news );
                  ((DynaActionForm)form).set( "subjects", subjects );

but now, how can I show it to the user in the jsp resulting from the forward on GetWelcomeInformationAction ??? ->> /teacher/welcome.jsp"

so far. I have this welcome.jsp

Code:

<%@ page contentType="text/html; charset=utf-8" %>

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

<html:html locale="true">

<head>

<title><bean:message key="common.label.title"/></title>
</head>
<html:base/>
<body>

        <bean:message key="teacher.welcome.welcome"/>
        <html:errors/>       
<%-- Iterate through the accounts and print them out inside the table --%>
<logic:iterate name="getWelcomeInformationForm" property="news">


</logic:iterate>

</body>
</html:html>

but I dunno how to really "iterate" .................. please any help?

Thanks a lot for even reading this large post :)

Poeta

perry 09-06-2005 02:08 PM

along the same lines...
 
here's a couple of vendors that offer intergrated debugging for struts and jsps, anybody know of other providers?

Eclipse add-ons for struts and jsps

Nitrox struts and jsps editors/debuggers

would love to know a cheaper alternative (free is good) anybody know of anything "free" along these lines

thanks much

- perry

mrcheeks 09-06-2005 02:36 PM

You should have read more about jsp/jstl/struts:

you can use bean:write or jstl, see for example :http://technology.amis.nl/blog/index.php?p=133


All times are GMT -5. The time now is 10:03 PM.