because it shows it can't find anything for "county" attribute ALTHOUGH I supplied it in the access URL.
If I am accessing a regular HttpServlet (instead of Astruts 2) then in servlet's "get" method I was able to get it. But in action class, why can my
HttpServletRequest only retrieve variables that are sdefined in the class ? Please help explain. Thanks.
Firstly, was an attribute named 'county' set somewhere that you're trying to get through getAttribute method?
The part of the URL:
signifies county is a request parameter and NOT a request attribute. In Struts2, since you don't have an ActionForm, parameters and their getters/setters are coded in the Action class. I'd sugest understanding the differences between attributes and parametes in various scopes. These links could be helpful in understanding them:
Link1 (remove %20) in the URL.
Help us help you by providing us with actual error messages.
Coderanch, best ever forum on the net. Hands down.
mark I thomas
Joined: Apr 07, 2008
yes "county" is passed as parameter. In this case, should the action class extends "ParamterAware" stuff ?
what's the syntax to retrieve this parameter value in action's method ?
You don't have to. I believe you had gone through the methods(well there's only one I believe) of ParameterAware. I'd recommend implementing ServletRequestAware instead which would give you the access to request object. You guessed it, there's ServletResponseAware and SessionAware interfaces too. Thing is the request(and response/session) object(s) would be injected through respective setters. This example should give you more insight into using these objects. Hope that helps.