Question

I'm looking for something like that in Struts 2 :

<s:textfield name="name" value="%{#request.getRemoteUser()}" 
                              label="Evaluateur"  required="true" />

this not work and I'm testing

<s:textfield name="name" value="<%=request.getRemoteUser()%>"
                              label="Evaluateur"  required="true" />
Was it helpful?

Solution

You can get a HttpServletRequest object in JSP from the action context with com.opensymphony.xwork2.dispatcher.HttpServletRequest key or by using static property of StrutsStatics interface.

<s:textfield value="%{#context[@org.apache.struts2.StrutsStatics@HTTP_REQUEST].getRemoteUser()}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top