16

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,037
  • 11
  • 49
  • 86

2 Answers2

21

If get an attribute from 'session', try this ${username}.

If get an parameter from 'request', try this ${param.username}.

CE ZHANG
  • 507
  • 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,131
  • 3
  • 28
  • 56
  • For request attributes you should use quotes to wrap the parameter's name. ${param['name']} – Khaled Dec 08 '16 at 09:54