tags:

views:

154

answers:

2

Hello, Can this method work?

public String sayHello(){
    return "Hello.jsp?name=" + "laala";
}

I am unable to access, query string using the above method. I tried ${param.name} as well as request.getParameter("name"). They both return null. Please help!

+2  A: 

maybe this would help you. check out f:param with h:commandLink

http://balusc.blogspot.com/2006/06/communication-in-jsf.html

daedlus
+3  A: 

Either fire a redirect..

public void sayHello(){
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("/Hello.jsp?name=" + "laala");
}

.. or if you're already on JSF2, then just define them in navigation case:

<to-view-id>/Hello.jsp?name=#{bean.property}</to-view-id>

(although the .jsp file extension less or more hints that you're not on JSF2 yet)

When using the JSF2 navigation case, if you want the new URL get reflected in the browser address bar, you need to add a <redirect/> entry, else it will just do a forward.

BalusC