Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp 注册后自动访问主页_Jsp_Servlets_Jsf 2_Primefaces - Fatal编程技术网

Jsp 注册后自动访问主页

Jsp 注册后自动访问主页,jsp,servlets,jsf-2,primefaces,Jsp,Servlets,Jsf 2,Primefaces,我有一个注册表单,用户可以在其中填写必须填写的字段和帐户。一旦提交,他将被重定向到登录页面,在那里他应该输入登录名和密码以访问主页 登记表 <h:form id="newCustomerForm" > <fieldset> <legend>Register Form</legend> <table border="0" >

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

登记表

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

登录

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

您不想在登录表单中填写密码。这将公开用户的密码。您可以继续设置会话参数,在重定向之前将其显示为已登录。您的意思是,如果登录凭据正常,则将其重定向到主页,否则将其重定向到登录页面,并在其输入的相应字段中设置用户名和密码?如果是这样,那么您可以将用户名和密码保存为请求属性,如request.setAttribute(“username”,userNameString);并在登录页面上再次获取它