This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Struts and the fly likes how can request in Struts' action get parameters from url? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how can request in Struts Watch "how can request in Struts New topic
Author

how can request in Struts' action get parameters from url?

Sean Li
Ranch Hand

Joined: Feb 27, 2002
Posts: 154
i have a link of this kind: test.do?action=create.
and in my testAction file, i wrote:
String action=request.getAttribute("action");
but later when i was using the variable action, the system tell me the action is null. why? i don't know how this comes.
so how can i get parameters from the url in Struts?
please help me, thanks!
Sean Li
Ranch Hand

Joined: Feb 27, 2002
Posts: 154
should be:
String action=(String)req.getParameter("action");
Ron Ditch
Ranch Hand

Joined: May 16, 2002
Posts: 33
Just add a string field to your view bean with the name of the URL parameter.
Struts will populate your form bean with the URL parameter.
 
 
subject: how can request in Struts' action get parameters from url?
 
Similar Threads
linking struts2 action to pre-existing pure Java servlet
Missing request parameters after action chaining
Pass parameters between 2 EARs.
Struts 2 - passing request parameters on the fly during redirectAction result type
repopulating form