注册后自动访问主页

时间:2014-03-03 14:52:46

标签: jsp servlets jsf-2 primefaces

我有一个注册表单,用户填写必填字段和帐户。一旦提交,他将被重定向到登录页面,在那里他应该输入他的登录名和密码才能访问主页

注册表格

<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>

我的目标是如何在将表单提交到主页或带有填写的登录名和密码的登录页面后重定向用户(无需手动重新输入) 有什么想法吗?

0 个答案:

没有答案