Return-Path: Delivered-To: apmail-struts-user-archive@www.apache.org Received: (qmail 15286 invoked from network); 30 Aug 2007 16:13:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 30 Aug 2007 16:13:26 -0000 Received: (qmail 53147 invoked by uid 500); 30 Aug 2007 16:13:11 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 53123 invoked by uid 500); 30 Aug 2007 16:13:11 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 53111 invoked by uid 99); 30 Aug 2007 16:13:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Aug 2007 09:13:11 -0700 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [66.196.97.61] (HELO web56702.mail.re3.yahoo.com) (66.196.97.61) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 30 Aug 2007 16:13:03 +0000 Received: (qmail 80707 invoked by uid 60001); 30 Aug 2007 16:12:43 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=rWQyuMZMm1cVGQazwWXo3IMeG0/f5FnPhKd58zMMAQ4GHpuHGHcXtTN3pnsuAE2MFjlqIcB3byDjLO/IS/U4ZvyMtXDzgARpgsqsVEsEGAFU0XyCB5ni2ffc9XCoNEXjUXNikGG9kOwHYLFpZWCh61KCA8nj8m8pUTITOH+Bh1k=; X-YMail-OSG: JgQCXAMVM1lBWmQ7lybx_3HOnM.9soJUw19.RpHLwwlmGWAm4QGghuXP.4dX7O76Lx5TMjRq1TiFUhYJQ224N6x9URmY0HGCoGyV7mkS4unO4.vXZfo- Received: from [63.166.14.2] by web56702.mail.re3.yahoo.com via HTTP; Thu, 30 Aug 2007 09:12:42 PDT Date: Thu, 30 Aug 2007 09:12:42 -0700 (PDT) From: Dave Newton Subject: Re: How to access request & session objects in jsp using struts2 tags To: Struts Users Mailing List In-Reply-To: <42db7f0a0708300906w7e363370y7a97bd152171914a@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <69360.80647.qm@web56702.mail.re3.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org > 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 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 > 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 > > action="InitAction_stub" type="image" > > title="Continue" /> > > > > The piece of code where I am trying to check for > the button in the jsp > > > > HI > > value="%{'All'}" /> > > <% > request.setAttribute("currentSection","All"); %> > > > > > > <% > request.setAttribute("currentSection","no"); %> > > > > > > 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 > > > > 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 > 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 > 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: > user-unsubscribe@struts.apache.org > > For additional commands, e-mail: > user-help@struts.apache.org > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > user-unsubscribe@struts.apache.org > For additional commands, e-mail: > user-help@struts.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@struts.apache.org For additional commands, e-mail: user-help@struts.apache.org