My view would be that you would not want to mandate in your development
approach
that all HTTP headers -- including cookies -- are set by a controller
servlet, and
none by a JSP.  I like the ability to control on a page by page basis
whether a page is cacheable -- this involves setting the Cache-Control and
Pragma
headers.  A cookie is just a special case of header, so I wouldn't mandate
not
setting one kind of header, but allowing others.

For cookies in particular, the main use I see -- apart from managing the
client's
session and user-identity -- is to record state between requests.  This
state
needs to be understood and managed by the controller, so I would say the
controller
servlet should be the only entity that sets cookies of this type.  But
unless the
state-info is very long or you somehow want to hide it, I would use query
parameters
for this kind of state.

- Fernando



                                                                                       
                                                           
                    Darren_Richmond@t                                                  
                                                           
                    rilogy.com              To:     [EMAIL PROTECTED]     
                                                           
                                            cc:     (bcc: Fernando Salazar/CAM/Lotus)  
                                                           
                    10/02/2001 10:57        Subject:     Re: Can't use Cookies in tag 
libraries ?????                                             
                    AM                                                                 
                                                           
                    Please respond to                                                  
                                                           
                    struts-user                                                        
                                                           
                                                                                       
                                                           
                                                                                       
                                                           





This seems to raise an interesting, generic question: in Model2, is it
always desirable (or necessary) to set cookies in a controller servlet?
What strategies for setting cookies (as part of request
handling/dispatching) are most common in struts?



                    Marcel May

                    <Marcel.May@co       To:
[EMAIL PROTECTED], "[EMAIL PROTECTED]"
                    nsol.de>              <[EMAIL PROTECTED]>

                                         cc:
"'[EMAIL PROTECTED]'"
                    10/02/2001            <[EMAIL PROTECTED]>

                    09:39 AM             Subject:     Re: Can't use Cookies
in tag libraries ?????
                    Please respond

                    to struts-user







Store your information in a bean with e.g. session scope?
Is much simpler ...

On Tue, Oct 02, 2001 at 04:40:05PM +0200, Arnaud H?ritier wrote:
> After studying the problem, I'm agree with you Fernando.
> It's not a good idea to access to the header components from a
taglibrary.
> I found a bypass to my problem substituting a <jsp:include> tag which
flush
> the content by a <@ include> which doesn't.
> It works in this case but it's very bad and it reduces enormously the
reuse
> of my taglibrary.
> I thinks that this problem is very annoying. I wouldn't do a very
> complicated thing. I developped a page by page iterator, and I wanted to
> store from the taglibrary in a cookie the number of lines selected by the
> user, in order to be transparent in the jsp page.
> what a shame that cookies are transfered in the header :-(
>
> too bad for me
>
> arno
>
>
> > -----Message d'origine-----
> > De:   [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> > Date: mardi 2 octobre 2001 16:16
> > ?:    [EMAIL PROTECTED]
> > Cc:   Tomcat-User (Adresse de messagerie)
> > Objet:     RE: Can't use Cookies in tag libraries ?????
> >
> >
> > I would say its not good practice for a taglib to write any HTTP header
> --
> > of course,  that includes cookies.
> > Since tag extensions are designed to make scripted markup more
> expressive,
> > compact, etc., they have to
> > be allowed anywhere that markup is allowed.  If possibly Struts is
> causing
> > headers to be committed sooner
> > that you are used to, even if Struts did nothing, you could still never
> > insure that your tag would be successfully
> > be able to write a cookie in all instances -- there's nothing to stop
> your
> > tag from being included at the bottom
> > of a 50K JSP page.  Unless the servlet container had a large buffer,
the
> > headers would already be committed.
> >
> > In apps I've worked on, we've always had a usage of putting any
> statements
> > that write headers -- those controlling page
> > caching, for example -- at the top of our JSP's, before any markup is
> > transmitted.  The mechanism is not
> > foolproof, in that it relies on developers to understand and employ the
> > usage, but then again this is no more
> > burdensome that the 100 other things you need to know to make this
stuff
> > operate correctly.
> >
> > - Fernando
> >
> >
> >
> >
>
> >                     Arnaud
>
> >                     H?ritier             To:     "Tomcat-User (Adresse
de
> messagerie)" <[EMAIL PROTECTED]>
> >                     <aheritier@sop       cc:     "Struts-User (Adresse
de
> messagerie)" <[EMAIL PROTECTED]>, (bcc: Fernando
> >                     ra.com>               Salazar/CAM/Lotus)
>
> >                                          Subject:     RE: Can't use
> Cookies in tag libraries ?????
> >                     10/02/2001
>
> >                     07:42 AM
>
> >                     Please respond
>
> >                     to struts-user
>
> >
>
> >
>
> >
> >
> >
> >
> > Same think if I try to add a Cookie in the response from a JSP page :-(
> >
> > Sniffff
> >
> > I found that the response is already commited when I'm in the JSP Page.
> > I don't undestand why !!!
> > I use a servlet (Action Servlet from Struts Framework) which forward,
> after
> > an action, to my JSP page.
> >
> > Can I bypass the commit of the response ???
> >
> >
> >
> >
> > > -----Message d'origine-----
> > > De:           Arnaud H?ritier [SMTP:[EMAIL PROTECTED]]
> > > Date:         mardi 2 octobre 2001 12:13
> > > ?:       Tomcat-User (Adresse de messagerie)
> > > Objet:        RE: Can't use Cookies in tag libraries ?????
> > >
> > > I just try to test with tomcat 4.0 standalone and I have the same
> problem
> > :-(
> > >
> > > Craig, an idea ????
> > >
> > > > -----Message d'origine-----
> > > > De:         Arnaud H?ritier [SMTP:[EMAIL PROTECTED]]
> > > > Date:       mardi 2 octobre 2001 12:03
> > > > ?:          Tomcat-User (Adresse de messagerie)
> > > > Objet:           Can't use Cookies in tag libraries ?????
> > > >
> > > > Hi all !!
> > > >
> > > > I face up to a problem concerning the use of cookies in a tag
> library.
> > > >
> > > > In my tag library I would like to store a cookie on the client.
> > > > I wrote this in the doStartTag method of my tag :
> > > >
> > > >        HttpServletResponse httpResponse
> > = (HttpServletResponse)pageContext.getResponse();
> > > >        Cookie cookie = new Cookie("myCookie","cookie");
> > > >        httpResponse.addCookie(cookie);
> > > >
> > > > but when later I retreive the list of cookies, this one is lacking.
> > > >
> > > > I tried to create cookies in my servlet and it works fine.
> > > >
> > > > I don't understand what it can happen !!!
> > > >
> > > > Can't we use cookies from tag libraries ????
> > > >
> > > > my configuration is :
> > > > Tomcat 3.2.3
> > > > AJP1.2
> > > > Apache 1.3.20
> > > > IE5.5
> > > >
> > > >
> > > > Have you any ideas ???
> > > >
> > > > thanks
> > > >
> > > >
> > > > Arnaud HERITIER
> > > > Ing?nieur d'?tudes
> > > > SOPRA. Group
> > > > EAI Consulting
> > > > Tel : +33-1-53-33-44-74
> > > > Email : [EMAIL PROTECTED]
> > > >
> >
> >
> >
> >

--
Marcel May
Development
ConSol* GmbH

(See attached file: C.DTF)

C.DTF

Reply via email to