jsp:useBean重复id检查

时间:2014-06-20 04:51:27

标签: java jsp tomcat7

在我的jsp页面中,我有以下代码片段。在我的流程中,这个页面以递归的方式进行。我在流程中间执行jsp时遇到重复的bean id错误。你能帮助我如何检查bean id是否已经存在以下代码?

已提供完整代码

    code.jsp

<%@ page language="java" %>   
<%@ page import="com.ubsw.risk.AUT_Authenticator.*" %>

<%
   String path= System.getProperty("dev_property_path");   
   System.out.println("dev_property_path----->"+path); 
%>
<jsp:useBean id="orbinfra" scope="session" class="com.ubsw.risk.Creation.web.OrbinfraBean" >
<jsp:setProperty name="orbinfra" property="propertiesFile" value="<%=path%>"/>
<%
    System.out.println("B4 init of Orbinfra");
    try {
        orbinfra.init();
            System.out.println("after init of Orbinfra");
    } catch( Exception ex ) {
        System.out.println("error in Orbinfra"+ex);
        ex.printStackTrace();
%>
    <html>
        Caught exception while creating orbinfra <%= ex %>
    </html>
<%
    }
%>
</jsp:useBean>
<jsp:useBean id="security" scope="session" class="com.ubsw.risk.Creation.web.AuthenticatorBean" >
</jsp:useBean> 

<%
    boolean showLogin;
    showLogin = true;
    boolean additionalMessage = false;
    String message = "Warning - Users login has expired";
    boolean hasAdminRights = false;
    // is there a command being sent
    String checkcommand = request.getParameter("command");

    // does user want to login
    if( checkcommand != null ) {
        if( checkcommand.equals("login") ) {
            try {
                    String authenticatorModuleLookupValue= System.getProperty("authenticatorModuleLookupValue");
                    String cookieNamevalue= System.getProperty("cookieNamevalue");
                    System.out.println(request.getParameter("User_Name"));              
                    System.out.println(request.getRemoteAddr());                
                    System.out.println(request.getLocalAddr()); 
                    System.out.println("hello P"); 
                //HttpSession session1 = request.getSession(true);
                 System.out.println(authenticatorModuleLookupValue+":"+cookieNamevalue);
                                security.setloginInfo(authenticatorModuleLookupValue,cookieNamevalue);
                security.logon(request.getParameter("User_Name"), request.getParameter("Password"), request.getRemoteAddr(), response );            
                System.out.println("what happened?");System.out.println(security);
                showLogin = false;
            } catch( LogonFailure le ) {
                additionalMessage = true;
                message = "Logon failed : " + le.reason;
            } catch( Exception ex ) {
                additionalMessage = true;
                message = "Failed, caught an exception : " + ex;
            }
        }
    }

    if( showLogin ) {   
        try {
            showLogin = !security.hasPermission( request );
            if( ! showLogin ) {
                hasAdminRights = security.hasAdminPermission( request );
            }
        } catch( TicketIsExpired te ) {
            additionalMessage = true;
            message = "Warning - Users login has expired";
        } catch( Exception ex ) {
            additionalMessage = true;
            message = "Exception - " + ex;
        }
    } 
//System.out.println("showLogin"+showLogin);
    // do we need to show login or not
    if( showLogin ) {
    %>

    <html>
    <body>
    <FORM NAME="loginForm" ACTION="index.jsp" METHOD="post">
    <center>
    <%
            if( additionalMessage ) {
    %>
                <b> <%= message %> </b><br>
    <%
            }
            //System.out.println("showLogin"+showLogin);
    %>


    <br>
    <br>
    <center>
    <table cellspacing="0" cellpadding="0" border="2" bordercolor="#60A0A0">
        <INPUT TYPE='hidden' NAME='command' VALUE='login'>
        <body>


                    <tr bgcolor="#60A0A0">
                                    <td align="left" height="17"><font face="Verdana" color="white"><span
                                        style="color: white; font-weight: bold; font-variant: normal; font-size: 10pt; text-align: left">
                                        <center>
                                        Creation Web Application
                                        </center>
                                        </span></font></td>
        </tr>
                <tr bgcolor="#60A0A0">
                <td align="left" height="17"><font face="Verdana" color="white"><span
                    style="color: white; font-weight: bold; font-variant: normal; font-size: 10pt; text-align: left">Please 
                Login</span></font></td>
            </tr>
            <tr>
                <td align="left" height="166">
                <table border="0" height="116" width="460">
                    <tbody>
                        <tr>
                            <td height="16" width="70"></td>
                            <td height="16" width="87"></td>
                            <td height="16" width="164"></td>
                            <td height="16" width="136"></td>
                        </tr>
                        <tr>
                            <td height="25" width="70"></td>
                            <td height="25" width="87"><span
                                style="color: black; font-style: normal; font-family: Verdana; font-weight: bold; font-size: 10pt; text-align: center">Username:</span></td>
                            <td height="25" width="164"><input type="text"
                                name="User_Name" maxlength="20"
                                style="height: 25px; font-family: Verdana; width: 153px"></td>

                        </tr>
                        <tr>
                            <td height="1" width="70"></td>
                            <td height="1" width="87"></td>
                            <td height="1" width="164"></td>
                            <td height="1" width="136"></td>
                        </tr>
                        <tr>
                            <td height="25" width="70"></td>
                            <td height="25" width="87"><span
                                style="color: black; font-style: normal; font-family: Verdana; font-weight: bold; font-size: 10pt; text-align: center">Password:</span></td>
                            <td height="25" width="164"><input type="password"
                                name="Password"
                                style="height: 25px; font-family: Verdana; width: 153px"
                                maxlength="25"></td>
                            <td height="25" width="136"></td>
                        </tr>
                        <tr>
                            <td height="19" width="70"></td>
                            <td height="19" width="87"></td>
                            <td height="19" width="164"></td>
                            <td height="19" width="136"></td>
                        </tr>
                        <tr>
                            <td height="27" width="70"></td>
                            <td height="27" width="100"></td>
                            <td height="27" width="136">
                            <center><input type="submit" name="Login"
                                value="Login"
                                style="height: 25px; bottom: auto; right: auto; font-family: Verdana; background-color: #60A0A0; width: 62px; top: auto; left: auto"></center></td>
                        </tr>
                        <tr>
                            <td height="1" width="70"></td>
                            <td height="1" width="87"></td>
                            <td height="1" width="164"></td>
                            <td height="1" width="136"></td>
                        </tr>
                    </tbody>
                </table>
                </td>
            </tr>
        </tbody>
    </table>
    </center>
    </FORM>
    </body>
</html>

    <%
            return;
        }
    %>

1 个答案:

答案 0 :(得分:0)

正如您所说This page is coming recursive way during my flow.

尝试将scope="page"更改为scope="request"

或尝试将beanId重命名为"orbinfra1"

<jsp:useBean id="orbinfra1" scope="session" class="com.ubsw.risk.Creation.web.OrbinfraBean" >    
    <jsp:setProperty name="orbinfra1" property="propertiesFile" value="<%=path%>"/>
</jsp:useBean>