Thanks for you help Craig. I think the <meta> tag looks the cleanest way and I'll use that.
Regards Jim. ----- Original Message ----- From: "Craig McClanahan" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, April 14, 2004 5:50 AM Subject: Re: Slightly OT How to set a request header using JSTL > Michael McGrady wrote: > > > Couldn't he wrap the response object inside a getter/setter facade? > > > I suppose one could do that, and even stick it (the response object) > into the request attributes to make it visible to the EL via the > "requestScope" magic variable. But a property setter only takes a > single argument (the value), so you'd need a property setter for every > possible header (which is technically infeasible, since the set of > possible headers is unbounded), and you still wouldn't be able to deal > with the cases where more than one value for a header can be added (via > response.addHeader()). > > It is a far far better thing :-) to just use the <meta> tag that HTML > provides for exactly this sort of purpose. > > <meta http-equiv="Header-Name" content="${the.value.for.this.header}"> > > Besides the performance advantages of skipping all the mapping and > facading, and making people scratch their heads over the resulting EL > expressions, this has the advantage of clearly describing what's going > on to anyone who is familiar with HTML. > > Craig > > > > At 06:56 PM 4/13/2004, Craig McClanahan wrote: > > > >> Jim Collins wrote: > >> > >>> Hi Craig, > >>> > >>> Thanks for your response. I wanted to set the header in the JSP page > >>> itself. > >>> At the moment I set the header using a scriptlet (as you described > >>> in your > >>> post) but I would like to disable scriptlets in my JSP pages. > >>> I was playing around with the EL and could print out the headers > >>> using this > >>> but I could find no way to set a header. I believe that Struts > >>> provide a tag > >>> that encapsulates the response that I could manipulate using the EL > >>> but I > >>> was wondering if I could do it using the explicit response object in > >>> the EL. > >>> > >>> > >> Unfortunately the "response" implicit object (that the JSP page > >> compiler provides) is not visible through the EL directly. Even if > >> it were, however, it wouldn't help much because you can only call > >> property getters with EL expressions; not arbitrary methods with > >> arbitrary parameters. > >> > >>> Regards > >>> > >>> Jim. > >>> > >> > >> Craig > >> > >> > >>> ----- Original Message ----- From: "Craig McClanahan" > >>> <[EMAIL PROTECTED]> > >>> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >>> Sent: Tuesday, April 13, 2004 10:48 PM > >>> Subject: Re: Slightly OT How to set a request header using JSTL > >>> > >>> > >>> > >>> > >>>> Jim Collins wrote: > >>>> > >>>> > >>>> > >>>>> Hi, > >>>>> > >>>>> Has anyone any thoughts on this? > >>>>> > >>>>> > >>>>> > >>>>> > >>>> The "header" object relates to the *request* headers. You can set > >>>> *response* headers in a number of ways: > >>>> > >>>> * (Servlet 2.3 or later) in a Filter that wraps and postprocesses > >>>> the response > >>>> > >>>> * In your Action (although that only works if you also do the output > >>>> itself; doing a request dispatcher forward will clear the headers). > >>>> > >>>> * In a JSP page with scriptlets (as long as it's before the response > >>>> is committed): > >>>> > >>>> <% > >>>> response.setHeader("Foo", "bar"); > >>>> %> > >>>> > >>>> * In a JSP page with HTML <meta> tags in the <head> section: > >>>> > >>>> <meta http-equiv="Foo" content="bar"> > >>>> > >>>> * (JSP 2.0 or later) you can use EL expressions to get the value part > >>>> of the header from a bean property dynamically: > >>>> > >>>> <meta http-equiv="Foo" content="${mybean.fooValue}"> > >>>> > >>>> * Ugly but workable using a Struts tag get the dynamic value: > >>>> > >>>> <meta http-equiv="Foo" > >>>> content='<bean:write name="mybean" property="fooValue"/>'> > >>>> > >>>> This only works because <meta> is not a custom tag; otherwise > >>>> the nesting syntax would be illegal. > >>>> > >>>> > >>>> > >>>>> Thanks > >>>>> > >>>>> Jim. > >>>>> > >>>>> > >>>>> > >>>> Craig > >>>> > >>>> > >>>> > >>>> > >>>>> ----- Original Message ----- From: "Jim Collins" > >>>>> <[EMAIL PROTECTED]> > >>>>> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > >>>>> Sent: Tuesday, April 06, 2004 10:10 PM > >>>>> Subject: Slightly OT How to set a request header using JSTL > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>> Hi, > >>>>>> > >>>>>> I know how I can read request headers using c:out and the header > >>>>>> object. > >>>>>> Does anyone know how I can set a response header using c:set? Can > >>>>>> it be > >>>>>> > >>>>>> > >>>>>> > >>>>> done > >>>>> > >>>>> > >>>>> > >>>>> > >>>>>> without using the response tag? I don't want to use scriptlets. > >>>>>> > >>>>>> Thanks > >>>>>> > >>>>>> Jim. > >>>>>> > >>>>>> > >>>>>> --------------------------------------------------------------------- > >>>>>> > >>>>>> 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] > >>>> > >>>> > >>>> > >>> > >>> > >>> --------------------------------------------------------------------- > >>> 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] > > > > --------------------------------------------------------------------- > 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]