Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Very Troubled In Finding Ways To Pass A Variable

 
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 ]
 
tumbleweed and gunslinger
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().
 
This cake looks terrible, but it tastes great! Now take a bite out of this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic