java - Get request header in JSP Struts2 -


i set header in action class. code follow:

public string domyaction() {      response.setheader("abc","cba");     response.addheader("abcdefg","1234567890");      return "target_page";  } 

at target_page.jsp, tried display header, value null.

<%= request.getheader("abc") %>           <-- null <%= request.getheader("abcdefg") %>       <-- null <%= response.containsheader("abc") %>     <-- true <s:property value="%{#request.abc}" />    <-- empty <s:text name="%{request.abc}" />          <-- empty <s:text name="%{#header.abc}" />          <-- empty <s:text name="%{#header['abc']}" />       <-- empty 

and in developer tools, there headers.

enter image description here

in struts-config.xml,

<action name="target_name" class="com.my.class">     <result name="target_page">/my/jsp/target_page.jsp</result> </action> 

why can't request header set in action class?

edit:

how can request header set in action class?

the response headers , request headers different sets of headers.

you can set response headers in server-side code. request headers set browser.

if want pass data action class jsp, use request attributes.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -