> Hi, thank you for your attention to my problem.  First
> all, I think that I am missing someting.  In order to
> use the <c:set ....> and <c:out ... > tags, I think
> that I have to import a taglib into my JSP and assign
> it with a prefix "c".  Which taglib should I import? 
> Right now, I have these:
> 
> <%@ taglib uri="/tags/struts-html" prefix="html" %>
> <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
> <%@ taglib uri="/tags/struts-logic" prefix="logic" %>
> <%@ taglib uri="/tags/tiles" prefix="tiles" %>
> <%@ taglib uri="/tags/request" prefix="req" %>

You are missing this one:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %> 

> 
> Second, 
> 
> <html:form action="/list/Message">
> <c:set var="cr" value="${articleForm.creator}"
> scope="session"/>
> <c:out value="${cr}"/>
> <html:submit>View/Send Messages</html:submit>
> </html:form>
> <%-- The statement below has no problem to write on
> the value --%>
> <bean:write name="articleForm" property="creator"/>
That's because you were missing the JSTL taglib directive
above.


> 
> Third, the mapping to the next JSP is:
> 
>     <action
>         roles="administrator,editor,contributor"
>         path="/list/Message"
>         forward=".message.Form"
>         name="postForm"
>         scope="session"
>         validate="false"/>
> 
Why are you defining an action path at all.
Once you add the JSTL taglib directive the following
line places the value in the session. There is no
need to submit.

<c:set var="cr" value="${articleForm.creator}" scope="session"/>


> Fourth, in the postForm.jsp, I try to retrieve the
> value of the String that is passed in a session object
> and print it out in a text field:
> 
> <bean:define id="author" name="cr" scope="session"
> type="java.lang.String"/>
> <html:text property="creator" value="<%=author%>"
> size="82" maxlength="25" tabindex="1"/>
> 
You could use Struts-EL and do something like:
<html_el:text property="creator" value="${cr}"/>

The Struts-EL taglib and jar file can be found in the /contrib directory
of the Struts distribution.


> Fifth, the error message is that "cr" cannot be found
> in the session scope.
> 
Once again, this is because the JSTL taglib directive is missing.


> -Caroline
> 
> --- Robert Taylor <[EMAIL PROTECTED]> wrote:
> > What exactly are you trying to accomplish? What's
> > the
> > high level view?
> > 
> > If you can explain your intent, maybe we can suggest
> > an easier
> > way to accomplish your goal.
> > 
> > Is articleForm associated with action mapping
> > "/list/Message"?
> > If so, then you could do something like:
> > 
> > <html:form action="/list/Message">
> > <html:hidden property="creator"/>
> > <html:submit>View/Send Messages</html:submit>
> > </html:form>
> > 
> > This of course, assumes you have already populated
> > creator in
> > articleForm in some other action using the same
> > form.
> > 
> > 
> > The action with mapping "/list/Message", which
> > processes articleForm could
> > do something like:
> > 
> > MyForm articleForm = (MyForm) form;
> > String creator = articleForm.getCreator();
> > request.getSession().setAttribute("creator",
> > creator);
> > return mapping.findForward("success");
> > 
> > 
> > In JSP#2 you could do something like this:
> > <c:out value="${creator}"/>
> > 
> > robert
> > 
> > 
> > > -----Original Message-----
> > > From: Caroline Jen [mailto:[EMAIL PROTECTED]
> > > Sent: Wednesday, December 17, 2003 8:25 PM
> > > To: Struts Users Mailing List
> > > Subject: RE: How To Output the Value of a String
> > That Is Passed From
> > > Another JSP?
> > >
> > >
> > > Hi, my JSP#1 and JSP#2 use different forms. 
> > However,
> > > property name in JSP#1 is the same as that in
> > JSP#2.
> > > I tried to pass this Sring and write it out in a
> > text
> > > field in JSP#2 and just could not get it right.  I
> > got
> > > this error
> > > message:
> > >
> > > [ServletException
> > in:/article/content/postForm.jsp]
> > > Cannot find bean cr in scope session'
> > >
> > > In my view.jsp, I put a String in a session
> > object:
> > >
> > >    <html:form action="/list/Message">
> > >    <c:set var="cr" value="${articleForm.creator}"
> > > scope="session"/>
> > >    <html:submit>View/Send Messages</html:submit>
> > >    </html:form>
> > >
> > > And in postForm.jsp, I tried to retrieve that
> > String
> > > and write it out in a text field this way:
> > >
> > >       <bean:define id="author" name="cr"
> > > scope="session" type="java.lang.String"/>
> > >       <html:text property="creator"
> > > value="<%=author%>" size="82" maxlength="25"
> > > tabindex="1"/>
> > >
> > > -Caroline
> > >
> > > --- Robert Taylor <[EMAIL PROTECTED]> wrote:
> > > > There are a couple (3) ways to do it.
> > > >
> > > > 1. Have both JSP#1 and 2 use the same form then
> > have
> > > > the action that
> > > > processes JSP#1 simply
> > > > forward to JSP#2 and Struts will auto-populate
> > the
> > > > field.
> > > >
> > > > 2. Have the action that processes JSP#1 forward
> > or
> > > > redirect to
> > > >    JSP#2 whose form has the same property name.
> > > > Place the create property
> > > >    value in the query string and Struts will
> > > > auto-populate the form
> > > >    in JSP#2.
> > > >
> > > > 3. Have the action that processes JSP#1 access
> > and
> > > > populate the form used
> > > >    in JSP#2 with the property then forward to
> > JSP#2.
> > > >
> > > > robert
> > > >
> > > > > -----Original Message-----
> > > > > From: Caroline Jen
> > [mailto:[EMAIL PROTECTED]
> > > > > Sent: Tuesday, December 16, 2003 8:33 PM
> > > > > To: [EMAIL PROTECTED]
> > > > > Subject: How To Output the Value Of a Hidden
> > > > Field?
> > > > >
> > > > >
> > > > > My JSP #2 receives a hidden field passed from
> > JSP
> > > > #1:
> > > > > <html:hidden property="creator"/>
> > > > >
> > > > > In the JSP #2, I have a text field:
> > > > > <html:text property="creator" size="82"
> > > > maxlength="25"
> > > > > tabindex="1"/>
> > > > >
> > > > > and I want the value of the hidden field to be
> > the
> > > > > text in the text field of the JSP #2.  Please
> > > > advise
> > > > > how to do it?
> > > > >
> > > > > __________________________________
> > > > > Do you Yahoo!?
> > > > > New Yahoo! Photos - easier uploading and
> > sharing.
> > > > > http://photos.yahoo.com/
> > > > >
> > > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail:
> > > > [EMAIL PROTECTED]
> > > > > For additional commands, e-mail:
> > > > [EMAIL PROTECTED]
> > > > >
> > > >
> > > >
> > > >
> > >
> >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> > > > [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
> > > > [EMAIL PROTECTED]
> > > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > New Yahoo! Photos - easier uploading and sharing.
> > > http://photos.yahoo.com/
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > >
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> New Yahoo! Photos - easier uploading and sharing.
> http://photos.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to