Если вы уже используете JSF 2.0, вы можете получить @ManagedProperty
и @PostConstruct
.
@ManagedBean
@RequestScoped
public class Activation {
@ManagedProperty(value="#{param.key}")
private String key;
private boolean valid;
@PostConstruct
public void init() {
valid = check(key); // And auto-login if valid?
}
// ...
}
, а затем в JSF, к которому обращается http://example.com/activate.jsf?key=somelonggeneratedkey
<h:panelGroup layout="block" rendered="#{activation.valid}">
<p>Your account is successfully activated!</p>
<p><h:link outcome="home">Go to home page</h:link></p>
</h:panelGroup>
<h:panelGroup layout="block" rendered="#{!activation.valid}">
<p>Activation failed! Please enter your email address to try once again.</p>
<h:form>
...
</h:form>
</h:panelGroup>