> On 8/30/07, afp wrote: >> I am trying to identify whether a button has >> been clicked or not in my **jsp**.
Emphasis mine. The real question is why is that being done in the JSP directly from the request parameters when it would probably be better to set a flag based on whatever business logic might be happening or access the value from an action property or determine if the submission-based differences could be better isolated with an application resource or different result, etc. --- Chris Pratt <[EMAIL PROTECTED]> wrote: > If you just need access to the Request Attributes, > try implementing > RequestAware in your action. If you need access to > other, more > Servlet specific, parts of the Request, you'll have > tto implement > ServletRequestAware. Similarly for Sessions, if you > just need the > attributes, implement SessionAware, if you need full > access implement > ServletRequestAware and call request.getSession(). > (*Chris*) > > On 8/30/07, afp <[EMAIL PROTECTED]> > wrote: > > > > Hi, > > > > I am trying to identify whether a button has > been clicked or not in my > > jsp. > > The way I do this or is trying to do this is to > access the request object > > and then check in that for the button name. The > code is as shown below > > > > The button which was clicked is coded as shown > below > > <s:submit value="Continue" > action="InitAction_stub" type="image" > > title="Continue" /> > > > > The piece of code where I am trying to check for > the button in the jsp > > <s:if test="#request['action:InitAction_stub.x'] > != null"> > > HI > > <s:set name="abc.currentDisplaySection" > value="%{'All'}" /> > > <% > request.setAttribute("currentSection","All"); %> > > </s:if> > > <s:else> > > <% > request.setAttribute("currentSection","no"); %> > > </s:else> > > > > Now I know that the parameter > "action:InitAction_stub.x" is present in the > > request Map as I can see that in the Action class > which later forwards to > > the jsp. But I am unable to access it in the jsp. > > > > Is the way I am trying to access the request > parameter wrong? > > If so how do I get a request parameter in the jsp > - I saw the following > > usage in one of the struts2 pages > > > > <s:property > value="#request['action:InitAction_stub.x']"/> this > shud ideally > > print out the value of the button or any other > request parameter. But > > nothing gets printed. So where am I going wrong > and what do I need to do? > > > > Also along with this is there any way I can do the > below without using > > scriptlets > > <% request.setAttribute("currentSection","All"); > %> > > > > Also say I have an object in my action class will > I be able to rewrite the > > value of that object by using the set statement > i.e. will <s:set > > name="abc.currentDisplaySection" value="%{'All'}" > /> where abc is an object > > which is specified in the action class and has > getters and setters. My doubt > > is whether the above statement will update the > currentDisplaySection > > variable under abc object?? so that if I say print > out the value later using > > a <s:property value="abc.currentDisplaySection"/> > it shud print out 'All". > > Will this work?? > > > > > > TIA, > > Arup > > -- > > View this message in context: > http://www.nabble.com/How-to-access-request---session-objects-in-jsp-using-struts2-tags-tf4354438.html#a12407850 > > Sent from the Struts - User mailing list archive > at Nabble.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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]