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]



Reply via email to