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]