JavaServer Faces - How to get values from a query string in URL in a jsf page?

if i have a url, http://my.com/?name=john+smith, how do i get the values from that url in a jsf page and then pass those values to a servlet? i know how to do that in jsp using "request.getParamter("name")" and save it in a bean and then forward to a servlet. But what about in jsf?
[296 byte] By [tom_chanskya] at [2007-11-26 23:07:16]
# 1

Hello,

Try this:

Map requestMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();

String name = (String) requestMap.get("name");

If isn't worked one of these methods probably will solve your problem.

FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap();

hth.

Guilherme_Kellera at 2007-7-10 14:01:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
You need the RequestParameterMap. But better design is to just define managed properties in the faces-config.xml so that those params will be put in the backing bean 'automatically'. Also see http://balusc.xs4all.nl/srv/dev-jep-com.html under the header "Passing GET parameters".
BalusCa at 2007-7-10 14:01:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

But better design is to just define managed

properties in the faces-config.xml so that those

params will be put in the backing bean

'automatically'.

But isn't more easy do this in the code ?

What is the benefits to do this in the faces-config.xml ?

Thank you in advice.

Guilherme_Kellera at 2007-7-10 14:01:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...