Automatically access to home page after register
-
19-10-2022 - |
Frage
I have a register form where a user fill required fields to have and account. Once he submit he will be redirected to the login page where he should enter his login and password to access to the home page
register form
<h:form id="newCustomerForm" >
<fieldset>
<legend>Register Form</legend>
<table border="0" >
<tbody >
<tr type="text">
<td>
<p:outputLabel value="Account Login :" for="pseudo"/>
</td>
<p:spacer height="5px" />
<td>
<p:inputText id="pseudo" value="#{customerMB.login}" title="Pseudo" required="true" requiredMessage="The Pseudo field is required.">
</p:inputText>
<p:watermark for="pseudo" value="Login" />
<p:message for="pseudo" display="text"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="password">
<td>
<p:outputLabel value="Password :" for="pwd1"/>
</td>
<p:spacer height="5px" />
<td>
<p:password id="pwd1" value="#{customerMB.password}" feedback="true" match="pwd2" label="Password 1" required="true" requiredMessage="The Password field is required."/>
<p:watermark for="pwd1" value="Password" />
<p:message for="pwd1"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="password">
<td>
<p:outputLabel value="Confirm password :" for="pwd2"/>
</td>
<p:spacer height="5px" />
<td>
<p:password id="pwd2" value="#{customerMB.password}" feedback="true" label="Password 2" required="true" requiredMessage="The confirm password field is required."/>
<p:watermark for="pwd2" value="Confirm Password" />
<p:message for="pwd2"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="text">
<td>
<p:outputLabel value="Email address :" for="email"/>
</td>
<p:spacer height="5px" />
<td>
<p:inputText id="email" value="#{customerMB.email}" title="Email" required="true" validatorMessage="Insert a valid email" requiredMessage="The Email field is required.">
<f:validateRegex pattern="([^.@]+)(\.[^.@]+)*@([^.@]+\.)+([^.@]+)" />
</p:inputText>
<p:watermark for="email" value="Email" />
<p:message for="email"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="text">
<td>
<p:outputLabel value="First Name :" for="name"/>
</td>
<p:spacer height="5px" />
<td>
<p:inputText id="name" value="#{customerMB.name}" title="Name" required="true" requiredMessage="The Name field is required." styleClass="error"/>
<p:watermark for="name" value="First Name" />
<p:message for="name"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="text">
<td>
<p:outputLabel value="Last Name :" for="familyName"/>
</td>
<p:spacer height="5px" />
<td>
<p:inputText id="familyName" value="#{customerMB.familyName}" title="FamilyName" required="true" requiredMessage="The FamilyName field is required."/>
<p:watermark for="familyName" value="Last Name" />
<p:message for="familyName"/>
</td>
</tr>
<p:spacer height="5px" />
<tr type="text">
<td>
<p:outputLabel value="Organization :" for="organisation"/>
</td>
<p:spacer height="5px" />
<td>
<p:inputText id="organisation" value="#{customerMB.organisation}" title="Organisation" required="true" requiredMessage="The Organisation field is required."/>
<p:watermark for="organisation" value="Organisation" />
<p:message for="organisation"/>
</td>
</tr>
</tbody>
</table>
<div type="submit" align="right" style="margin-top: 5px">
<p:commandButton style="margin-right: 20px" id="loginInput" value="Save" ajax="false" icon="ui-icon-circle-check" styleClass="ui-priority-primary" binding="#{customerMB.loginInput}" action="#{customerMB.addCustomer()}" >
<h:message for="loginInput" style="color: red;"/>
</p:commandButton>
<p:commandButton value="Cancel" icon="ui-icon-arrowrefresh-1-n" onclick="location.href = 'login.jsp';" process="@this" >
<p:resetInput target="newCustomerForm" />
</p:commandButton>
</div>
</fieldset>
</h:form>
login.jsp
<form method="POST" action="Authentication">
<h2>Login <img style="margin-left: 160px; margin-top: 2px" src="pictures/idp-icon.png" width="100" height="38" alt="idp-icon"/></h2>
<p><input type="text" name="username" placeholder="Login"></p>
<p><input type="password" name="password" placeholder="Password"></p>
<button type="submit"></button>
<% String erreur = (String) request.getAttribute("erreur");
if (erreur != null) {%>
<h3 align="center" style="color: #FB0008; font-size: inherit"> Incorrect Login/Password, try again</h3>
<% }%>
<form>
My objectif is how to redirect the user ,after subbmitting the form, either to the home page or to the login page with filled login and password( no need to re enter them manually) Any idea?
Keine korrekte Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow