I rewrite one project in JSF 2.0, so I must follow the rules of MVC. In a simplified form, there is a ManagedBean User with the String login property. And there is a user.xhtml that is mapped to user.jsf .

What is the best way for the MVC paradigm to organize the transfer of the login parameter so that the user.jsf can display information about a specific user?

The classic solution user.jsf?login=login , as I understand it, is not the best? Or maybe you need to use a servlet that will set the parameter in the session and will forward the request to user.jsf ?

    1 answer 1

    "Classic solution" is quite acceptable, especially since the URL of the user's page can be static.

    How myservlet?login=login , which will set the variable in the session and redirect to user.jsf will be different from user.jsf?login=login ? You do not need the variable login in the session either. (It makes no sense to use your servlets in JSF)

    You can get this parameter as follows:

     <f:metadata> <f:viewParam name="login" value="#{user.login}" /> </f:metadata> 

    or

     @ManagedProperty(value="#{param.login}") private String login;