Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Very Troubled In Finding Ways To Pass A Variable

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 this way:

and the value of the 'username' is obtained this way:

Due to my limited knowledge in Struts, I cannot figure out what to do. Let me explain the problem:
1. There is this method inside the FindEditorData.java:

Therefore, 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 declared this way:

I am stuck because I do not know how to pass 'username' to the FindEditorData.java. I cannot state:

because the FindEditorData is not a servlet and does not extend Action. The compiler will give me "cannot resolve symbol: request/session"
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.
[ December 05, 2003: Message edited by: JiaPei Jen ]
[ December 05, 2003: Message edited by: JiaPei Jen ]
 
David Yutzy
tumbleweed and gunslinger
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have your page post to a standard Action servlet, then create an instance of your class from there.
At that point, you have access to the request object (passed into the method via the Struts framework) and can pass the value to your class.
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a difficulty to make this class a regular servlet because there is this method inside the FindEditorData.java:

Therefore, 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().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic