Actually, you haven't illustrated it. You've just stated it.

In the ActionForm there are methods like validate() that accept as
parameters an ActionMapping and an httpServletRequest, and from the
httpServletRequest you can call getSession().

Same holds true in the Action class' execute() method.

So what is the problem with your class? Why can't you utilize it from
one of these places that you do have access to these things? What
exactly is stopping you here? Once you tell us, then you will have
illustrated the problem.

-J

> -----Original Message-----
> From: Caroline Jen [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, December 06, 2003 1:47 PM
> To: Struts Users Mailing List
> Subject: Re: Very Troubled in Finding Ways to Pass a Variable 
> to a Class
> 
> 
> I know how to pass a hidden field.  The problem is how
> to retrieve it in my Java class.  I have illustrated
> that my Java class does not extend HttpServlet or
> Action.
> 
> This Java class has a mapping in the struts-config.xml
> file:
> 
> type="org.apache.struts.scaffold.ProcessAction"
> parameter="org.XYZ.article.FindEditorData"
> name="articleForm"
> 
> -Caroline
> --- Timo <[EMAIL PROTECTED]> wrote:
> > Caroline,
> > The best way I use it to pass parameters to the
> > action class is via a hidden
> > attribute in the form, in your case the
> > "articleForm"
> > you can define the hidden attribute using
> > 
> >     <input type="hidden" name="hiddenField" 
> > value="<%=request.getRemoteUser();%>"/>
> > Good luck.
> > 
> > ----- Original Message -----
> > From: "Caroline Jen" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Friday, December 05, 2003 8:17 PM
> > Subject: Very Troubled in Finding Ways to Pass a
> > Variable to a Class
> > 
> > 
> > > I have a class FindEditorData.java.  I want to
> > pass a
> > > vairable 'username' to this class for some
> > processing.
> > >  This class is invoked from a JSP:
> > >
> > > <html:form action="/find/Category">
> > > <html:submit>View Articles</html:submit>
> > >
> > > and the value of the 'username' is obtained this
> > way:
> > >
> > > String username = request.getRemoteUser();
> > >
> > > Due to my limited knowledge in Struts,  I cannot
> > > figure out what to do.  Let me explain the
> > problem:
> > >
> > > 1. This class has this method:
> > >
> > >    public Object execute() throws Exception { ...
> > }
> > >
> > >    I do not make this class extends HttpServlet or
> > > extends Action.  I cannot nest a method inside a 
> doGet/doPost or the 
> > > Action's excute().
> > >
> > > 2. The action mapping in the struts-config.xml is
> > this
> > > way:
> > >     <action
> > >         roles="editor"
> > >         path="/find/Category"
> > >
> > > type="org.apache.struts.scaffold.ProcessAction"
> > >         parameter="org.XYZ.article.FindEditorData"
> > >         name="articleForm"
> > >         validate="false">
> > >        <forward
> > >             name="success"
> > >             path=".article.Result"/>
> > >     </action>
> > >
> > > I am stuck because I do not know how to pass
> > > 'username' to the FindEditorData.java.  I cannot
> > > state:
> > >
> > >    String username = request.getRemoteUser();
> > >    or
> > >    String username = (String)session.getAttribute( "EditorName" );
> > >
> > >    because the FindEditorData is not a servlet and
> > > does not extend Action.
> > >
> > > I cannot pass a hidden variable from the JSP
> > because I
> > > do not know how to retrieve the value of a hidden
> > > variable in a Java class.
> > >
> > > Need clever ideas.  Please help.
> > >
> > >
> > >
> > >
> > > __________________________________
> > > 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