JSP Expression Language get parameter
Asked Answered
M

2

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?

Montgolfier answered 5/11, 2014 at 0:40 Comment(0)
S
23

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

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

Storeroom answered 5/11, 2014 at 1:4 Comment(2)
Thank you. But can you please link me the source for this information?Montgolfier
You question is actually about object scope in JSP. For your reference, check this out: docs.oracle.com/javaee/1.4/tutorial/doc/JSPIntro7.htmlStoreroom
S
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,

Susi answered 5/11, 2014 at 5:46 Comment(1)
For request attributes you should use quotes to wrap the parameter's name. ${param['name']}Buryat

© 2022 - 2024 — McMap. All rights reserved.