18

I am trying to get a String parameter "username" from the request with Expression Language. I've done some research, but couldn't find a way to do so, I would like something similar to ${pageContext.request.parameter.username}

How get a specific request parameter, using only expression language?

Victor2748
  • 4,149
  • 13
  • 52
  • 89

2 Answers2

23

To get an attribute from session use ${myattr}.

To get a parameter from request use ${param.myparam}.

bluish
  • 26,356
  • 27
  • 122
  • 180
CE ZHANG
  • 527
  • 4
  • 7
  • Thank you. But can you please link me the source for this information? – Victor2748 Nov 05 '14 at 01:17
  • You question is actually about object scope in JSP. For your reference, check this out: http://docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.html – CE ZHANG Nov 05 '14 at 01:32
7

The syntax to get the attributes from session would be,

${sessionScope[name]}

And for the request attributes , you can use

${param[name]}

For more info,

Santhosh
  • 8,181
  • 4
  • 29
  • 56
  • For request attributes you should use quotes to wrap the parameter's name. ${param['name']} – Khaled Dec 08 '16 at 09:54