here is the jsp

****************************************************************************
*****************

<HTML>

<HEAD>
        <TITLE>Rights Master</TITLE>
        <Link rel="stylesheet" type="text/css" href="../MISCss.css" />
        <SCRIPT>
                function submitPage(formNm)
                {
                        if (document.A_Rght_MstrScrn.DRP_ROLE.value == "" ||
document.A_Rght_MstrScrn.DRP_VERTICAL.value == "") {
                                alert("Please select the role and the
company description.");
                                document.A_Rght_MstrScrn.DRP_ROLE.focus();
                                return false;
                        }
                        else {
                                document.A_Rght_MstrScrn.method = "post";
                                document.A_Rght_MstrScrn.action =
"A_Rght_MstrScrn.jsp";
                                document.A_Rght_MstrScrn.submit();
                                return true;
                        }
                }

                function checkChkBox() {

                }
        </SCRIPT>
</HEAD>

<BODY>
<%@ taglib uri="response" prefix="res" %>

<%@ page language="java" session="true" import="java.sql.*,
java.util.Enumeration, com.gtl.database.*, oracle.jdbc.driver.*,
oracle.sql.*"%>

<%-- Set the HTTP Header Cache-Control to no-cache --%>
<res:setheader name="Cache-Control">no-cache</res:setheader>
<%-- Set the HTTP Header Pragma to no-cache for Http1.0--%>
<res:setheader name="Pragma">no-cache</res:setheader>
<%-- Set the HTTP Header Expires to the current time --%>
<res:setdateheader name="Expires">0</res:setdateheader>

<jsp:useBean id="tmpDbBean" class="com.gtl.database.DbBean" />
<jsp:useBean id="log" class="com.gtl.fileIO.log.LogFileGeneration" />

<%! OracleConnection tmpDbCon;%>
<%! OracleConnectionPool ocpl;%>

<FORM METHOD=POST NAME="A_Rght_MstrScrn"
ACTION="../servlet/CreateRightMstr">

<H3 class="pagehead">Rights Creation</H3>
<%
        try{
                ocpl = (OracleConnectionPool)session.getAttribute("ocpl");
                tmpDbCon = (OracleConnection)ocpl.getConnection();
                //System.out.println("***"+request.getHeader("REFERER")  );
                System.out.println("***"+request.getRequestURI() );

                for (Enumeration e = request.getHeaderNames();
e.hasMoreElements(); )
                        System.out.println(e.nextElement());
%>
<jsp:setProperty name="tmpDbBean" property="conn" value="<%=tmpDbCon%>" />
<TABLE WIDTH="100%" class="entrytable">
<TR>
        <TD class="entry">Role:</TD>
        <TD class="entry">
                <SELECT NAME="DRP_ROLE">
                        <OPTION VALUE="">SELECT</OPTION>
<%
                String strRoleId = "SELECT RLE_ROLE_ID, RLE_ROLE_DESC FROM
A_ROLE_MSTR";
                ResultSet rsRoleId = tmpDbBean.execSQL(strRoleId);

                while (rsRoleId.next()){
%>
                        <OPTION VALUE="<%=rsRoleId.getInt(1)%>" <%=
request.getParameter("DRP_ROLE") != null ?
request.getParameter("DRP_ROLE").equals(rsRoleId.getString(1)) ? "selected"
: "" : ""%>>
                                <%=rsRoleId.getString(2)%>
                        </OPTION>
<%
                }
                rsRoleId.close();
                rsRoleId = null;
                tmpDbBean.closeStmt();
%>
                </SELECT>
        </TD>
        <TD class="entry">Vertical:</TD>
        <TD class="entry">
                <SELECT NAME="DRP_VERTICAL">
                        <OPTION VALUE="">SELECT</OPTION>
<%
                String strVertical = "SELECT CMP_CMPNY_CODE, CMP_CMPNY_DESC
FROM A_CMPN_MSTR";
                ResultSet rsVertical = tmpDbBean.execSQL(strVertical);

                while (rsVertical.next()){
%>
                        <OPTION VALUE="<%=rsVertical.getString(1)%>"
<%=request.getParameter("DRP_VERTICAL") != null ?
request.getParameter("DRP_VERTICAL").equals(rsVertical.getString(1)) ?
"selected" : "" : ""%>>
                                <%=rsVertical.getString(2)%>
                        </OPTION>
<%
                }
                rsVertical.close();
                rsVertical = null;
                tmpDbBean.closeStmt();
%>
                </SELECT>
        </TD>
        <TD class="entry">
                <INPUT TYPE="button" NAME="CMD_BUTTON" value="Get Reports"
onClick="return submitPage();">
        </TD>
</TR>
</TABLE>
<%
                String strRole  = request.getParameter("DRP_ROLE");
                strVertical             =
request.getParameter("DRP_VERTICAL");

                if (strRole     == null || strVertical == null)
                        return;
                else{
%>
        <BR>
        <Table class="tablemain" border="1" width="100%">
        <TR>
                <TD class="head">Report Name</td>
                <TD class="head">Access Rights</td>
        </tr>
<%
                        String strReport = "SELECT DISTINCT A.RPT_RPRT_ID,
A.RPT_RPRT_NAME, (SELECT COUNT(*) FROM A_RGH_MSTR WHERE RGH_ROLE_ID =
"+strRole+" AND RGH_CMPN_CODE = '"+strVertical+"' AND RGH_RPRT_ID =
A.RPT_RPRT_ID) FROM A_RPT_MSTR A, A_RGH_MSTR B WHERE A.RPT_RPRT_ID =
B.RGH_RPRT_ID(+)";
                        System.out.println(strReport);
                        ResultSet rsReport = tmpDbBean.execSQL(strReport);

                        while (rsReport.next())
                        {
%>
        <TR>
                <Td class="data"><%=rsReport.getString(2)%></td>
                <Td class="data">
                        <input type="checkbox" name="CHK_REPORT"
<%=rsReport.getInt(3) == 1 ? "checked" : ""%>
value="<%=rsReport.getInt(1)%>">Grant/Revoke Rights
                </td>
        </tr>
<%
                        }
                        rsReport.close();
                        rsReport = null;
                        tmpDbBean.closeStmt();
%>
        <TR>
                <TD colspan="2" class="tdbutton"><INPUT TYPE="submit"
name="CMD_SUBMIT" value="Create Rights" onClick="return
checkChkBox();"></td>
        </tr>
</table>
<%
                }
        } catch (Exception e){
                log.generateLog("A_Rght_MstrScrn.jsp", e);
        } finally{
                ocpl.releaseConnection(tmpDbCon);
        }
%>
</FORM>
</body>
</html>

****************************************************************************
*******************

here is the servlet

package com.gtl.corpmis.admin.adminservlets;

import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import oracle.jdbc.driver.*;
import oracle.sql.*;
import com.gtl.database.*;
import com.gtl.corpmis.admin.adminbean.*;

public class CreateRightMstr extends HttpServlet
{
        OracleConnection tmpDbCon;
        OracleConnectionPool ocpl;

        private RightsNT[] retNt(String[] strValues)
        {
                RightsNT[] rghnt;
                if (strValues == null){
                        rghnt = new RightsNT[1];
                        rghnt[0] = new RightsNT(new Integer(-1));
                }
                else{
                        int count = strValues.length;
                        rghnt = new RightsNT[count];
                        for (int i = 0; i < count; i++)
                                rghnt[i] = new RightsNT(new
Integer(strValues[i]));
                }
                return rghnt;
        }

        public void doPost(HttpServletRequest request,HttpServletResponse
response)
                                                throws
ServletException,IOException    {
                response.setContentType("text/html");
                PrintWriter out=response.getWriter();

                try     {
                        ServletContext context = getServletContext();
                        ocpl            =
(OracleConnectionPool)context.getAttribute("CONNECTION_POOL");
                        tmpDbCon        =
(OracleConnection)ocpl.getConnection();

                        DbProc dbProc = new DbProc();
                        dbProc.setConn(tmpDbCon);

                        int roleId                      =
Integer.parseInt(request.getParameter("DRP_ROLE"));
                        String strCmpCode       =
request.getParameter("DRP_VERTICAL");
                        String[] strValues      =
request.getParameterValues("CHK_REPORT");

                        int retVal =
dbProc.execAS_FUNC_INSERT_RIGHTS(roleId, strCmpCode, retNt(strValues));
                        System.out.println("retVal = "+retVal );

                        if (retVal == 0) {
                                ocpl.releaseConnection(tmpDbCon);
                                RequestDispatcher rd =
context.getRequestDispatcher("/admin/A_Rght_MstrScrn.jsp");
                                rd.forward(request, response);
                        }

          } // end of try
          catch (Exception e){
                  e.printStackTrace();
          }
          finally{
                  ocpl.releaseConnection(tmpDbCon);
          }
        }
}
****************************************************************************
************************

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to