以下代码验证员工是否已申请过帖子。如果已经应用,它将重定向到“PRINT”页面,否则将指向“ENTRY PAGE”。此应用还有一个方面。也就是说,员工也可以申请另一名低于干部的员工。这由“LOGIN_AS”变量检查。我面临的问题是..如果我将“LOGIN_AS”的条件置于if-else条件中......即使他/她已经填写了相同的条件,也允许员工为自己填写。如果我删除它,它将重定向到打印页面,但不允许员工申请下级干部员工。
“LOGIN_AS”取自入口页
<%
String appln= request.getParameter("appln");
int empid = Integer.parseInt(request.getParameter("empsrno"));
String login_as = request.getParameter("login_as");
session.putValue("Login_as",login_as);
java.sql.Statement stmt = conn.createStatement ();
String sql = "SELECT E.SRNO,RTRIM(P.EMAIL_ID),E.NAME,TO_CHAR(SYSDATE,'DD/MM/YYYY'),DECODE(E.SRNO,I.SRNO,1,0),"+
"(to_date('01-DEC-2012','dd/mm/yyyy')-trunc(sysdate)) ,"+
"DECODE(I.SRNO,'',0,I.SRNO),E.CADRE,I.ITSG_TYP "+
"FROM EMPFILE E,PFORM_EXCHANGE_USERS P,ONLINE_PFORM_ADMIN A,APPLN I "+
"WHERE E.SRNO = P.EMPLOYEE_ID AND E.SRNO = A.EMPLOYEE_ID(+) AND E.SRNO=I.SRNO(+) "+
"AND E.SRNO=" + request.getParameter("empsrno") +" AND I.APPLN_TYP(+)='APPLN3N12' ";
ResultSet rset = stmt.executeQuery(sql);
int x = 0;
int lastDt;
int itsg_eid = 0;
String applnTyp = "X";
if (rset.next())
{
if ( request.getParameter("empemail").trim().toLowerCase().concat("@licindia.com").equals(rset.getString(2).toLowerCase()))
{
session.putValue("USER",request.getParameter("empsrno"));
session.putValue("LOGIN","true");
session.putValue("ENAME",rset.getString(3));
session.putValue("EMAIL",rset.getString(2));
session.putValue("SYSDT",rset.getString(4));
session.putValue("APPLNTYP",appln);
x = rset.getInt(5);
lastDt = rset.getInt(6);
appln_eid = rset.getInt(7);
applnTyp = rset.getString(9);
rset.close();
stmt.close();
conn.close();
if (lastDt == 0)
{
%>
<jsp:forward page="appln_login.jsp"><jsp:param name="message" value="LAST DATE (16/11/2012) FOR SUBMISSION OF APPLICATION IS OVER !!!"/></jsp:forward>
<%
}
if (empid == appln_eid && (applnTyp.equals(itsg)) && login_as=="S")
{
session.putValue("PUSER",request.getParameter("empsrno"));
%>
<jsp:forward page="appln_print.jsp"></jsp:forward>
<% } else {
%>
<jsp:forward page="appln_entry.jsp"></jsp:forward>
<% }
%>
任何人都可以指示我纠正上述代码......
答案 0 :(得分:0)
替换if(empid == appln_eid&amp;&amp;(applnTyp.equals(appln)&amp;&amp; login_as ==“S”)
通过
if(empid == appln_eid&amp;&amp;(applnTyp.equals(appln))&amp;&amp; login_as.equals(“S”))