Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request parameter in jsp page

Tags:

struts2

Im setting my parameter in my jsp like so -

<s:url id="open" action="viewEvent">
                    <s:param name="eventName" value="eventName" />
                </s:url> <sj:a href="%{open}" targets="eventSearchResultsDiv">Open</sj:a>

How can I access this parameter in my jsp page. This does'nt seem to be working -

<s:property value="eventName" />

Although this works - <%= request.getParameter("eventName") %>

Thanks

like image 665
blue-sky Avatar asked Dec 10 '22 11:12

blue-sky


2 Answers

The documentation says :

Assuming there's a request parameter myParameter (e.g. http://host/myApp/myAction.action?myParameter=one).

<s:property value="%{#parameters.myParameter}" />
like image 173
JB Nizet Avatar answered Mar 21 '23 02:03

JB Nizet


There are some implicit objects in JSP pages that provide access to this sort of information. The one you are looking for is param. If you were writing jstl with c:out for example you could do:

<c:out value="${param.eventName}"/>

Or in your example:

<s:url id="open" action="viewEvent">
    <s:param name="eventname" value="${param.eventName}"/>
</s:url>
like image 37
pauld Avatar answered Mar 21 '23 02:03

pauld