• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting param value using EL pageContext.request obj

 
yogesh srinivasan
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

Is there any way to get parameter value from request in EL by using the request object.

We can use the ${param.pwd} [pwd - parameter name]

I tried something like this ${pageContext.request.parameter["pwd"]}
but this throws an excepton
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EL can't call any methods that require parameters.

So ServletRequest.getParameter(String) requires a parameter so it's EL equivalent:

$pageContext.request.parameter

can't be used.

There is a way of getting at the parameters, but it isn't pretty. If you look through the interface specs:

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletRequest.html

you need to find a getter method that doesn't require a parameter passed to it, but returns the request parameters in something you can access using normal EL syntax (arrays, maps etc.)

I'm happy posting the solution if you want, but half the knowledge is in the journey, and there's a mild gotcha in that journey which is worth discovering!

Rufus.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried something like this ${pageContext.request.parameter["pwd"]}
Why? You've got the regular way of doing it working, why are you trying altrenate things that won't work?
 
Rufus Addis
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear, I can understand why! Doing things an alternative, "wrong" way is a good way of discovering and understanding how and why things work the way they do.

As a child I enjoyed taking the backs off clocks and seeing the mechanisms rather than winding them up and reading the time!

I apply the same attitude in IT!

Rufus
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason you don't want to use EL's requestScope object ?
 
Victor Dolirio
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
requestScope provide a way for getting atributes of request, he wants a request parameter...

Doing things an alternative, "wrong" way is a good way of discovering and understanding


Rufus, I don't think you are wrong but I think there are some better ways to learn stuff than the try 'n error worth, like to learn with other's experience and knowledge.
[ October 15, 2008: Message edited by: Victor Dolirio ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
requestScope provide a way for getting atributes of request, he wants a request parameter...

Sorry, I didn't read the question properly.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic