Avatar of Musaab1
Musaab1
 asked on

Code explanation

Hello Everyone, I have sarted this new job and I am supposed to be upgrading the portal, the person who worked here before did not leave any documnetation of any code and fiile, I am also not a Java expert. Is there anyone who could look at the code and then explain it t me what is the purpose (explicitly) of this code I know it is calling lots of other function and files but I have hard time understaning this specific one.

If someone can please procide comments in detail.    


 sss
       
        <%

            //HttpSession session = request.getSession();
    com.svvc.rap.MySQLBridge rbridge = new com.svvc.rap.MySQLBridge();
    Statement rstmt = (Statement) rbridge.createStatement("raptable");
    ResultSet rtable;
    String rquery;
    int rcount;
   
   
    try{
    //rquery = "SELECT * FROM `rap`.`raptable` WHERE `Person`='" + user +"' AND `Week`='" + cal.get(Calendar.WEEK_OF_YEAR) + "' ORDER BY `Day`";
    rquery = "SELECT * FROM `rap`.`raptable` WHERE `Person`='aahooja' AND `Week`='31' ORDER BY `Day`";
    rtable = rstmt.executeQuery(rquery);
      }
      catch(Exception e)
      {
            rtable=null;
      }



    // determine properties of rtable

            String[] cNames = null;
           
            if (rtable.next()) {
                rtable.last();
                rcount = rtable.getRow();
                rtable.first();
        %>      
       
        <%
               
                ResultSetMetaData meta = rtable.getMetaData();
                cNames = new String[meta.getColumnCount()];
                Vector[] rcells = new Vector[cNames.length];

                for( int col = 0; col < cNames.length; col++) {
                    cNames[col] = meta.getColumnName(col + 1);
                    rcells[col] = new Vector();
                }

                // hold data from result set
                do{
                    for(int col = 0; col < cNames.length; col++) {
                        Object cell = table.getObject(cNames[col]);
                        rcells[col].add(cell);
                    }
                }while(table.next());



                // print column headings
                out.print("<TABLE border=0 width=100% cellpadding=2>");
                //out.print("<div id=\"div1\">");
                out.print("<thead>");




               
                out.print("<tr align=\"center\"><td colspan=15 bgcolor=\"navy\"><font face=\"Geneva, Arial\" color=\"white\" size=4> Search Rap Sheet</td></tr><tr bgcolor=\"lightblue\">");
                String rapcol="";
        %>

        <!-- <td bgcolor="white"> </td> -->      
       
        <%
            for(int col = 0; col < cNames.length; col++) {
                        rapcol = cNames[col];
                        //if (rapcol.equals("keyval")) rapcol="ID";
                        //if (rapcol.equals("HoursWorked")) rapcol="Hours";
                        if (!rapcol.equals("keyval") && !rapcol.equals("Person"))
                            out.print("<td align=\"center\"><font color=\"darkblue\" face=\"Geneva, Arial\" size=2><b>" +  rapcol +  "</b></font></td>");
            }

        %>
        <td><font color="darkblue" face="Geneva, Arial" size=3> Delete </font></td>
        <%
        out.println();
            out.print("<tr/>");

            out.print("</thead>");
            //out.print("</div>")
            %>
        <tr bgcolor="lightyellow"><td colspan="5">
        </td></tr>


        <%
            // print data row-wise
            boolean row = true;
            //out.print("<div id=\"div2\">");
            out.print("<tbody>");
            int count = 0;
            String ridvalue="";
            while(!rcells[0].isEmpty()) {
                count++;
                if (row) {
                    out.print("<tr>");
                    row = false;
                } else {
                    out.print("<tr bgcolor=\"lightgrey\">");
                    row = true;
                }
                String rapvalue;



                for(int col = 0; col < cNames.length; col++) {
                    rapvalue = rcells[col].remove(0).toString();



            /* if (cNames[col].equals("HoursWorked")) {

            double hour = Double.valueOf(rapvalue).doubleValue();
            hours += hour;
            }*/

                    if (col==1 || col==2 || col==4 || col==2 || col==8 || col==13 || col==14 || col==17) //not equal to person column
                    {    out.print("<font color=\"navy\" face=\"Geneva, Arial\" size=2>");

        %>
                       
                        <td align="center">

                            <%= rapvalue %>
                               
                        </td>


                   <% }  

            if (col==0) {
                ridvalue = rapvalue;
            }
            if (col==cNames.length-1) {

        %>
        <html:form action="/RAPDelete.do" method="post">
            <td align = "left">
                   
                <bean:define id="ids" name="eles" property="<%=ridvalue%>"/>
                <%
                    java.util.HashMap rparams = new java.util.HashMap();
                    rparams.put("id", ridvalue);
                    pageContext.setAttribute("rparamsName", rparams);
                %>
               
                <html:link onclick="return window.confirm('Are you sure you want to delete this entry?');" page="/RAPDelete.do" name="rparamsName">
                    del
                </html:link>
            </td>
        </html:form>
        <%
            }

            out.print("</font>");


            }
            out.print("</tr>");
        %>
        <%
                }
                //out.print("</div>");
                out.print("</tbody>");
                out.print("</TABLE>");


                }
            else
            {
                 %><i><br> You do not have any TaskId's stored. Click "Add a Task ID" above, or "Store" from the Task ID List to get started.</i><%
            }
        %>
Java

Avatar of undefined
Last Comment
Musaab1

8/22/2022 - Mon
Ajay-Singh

Looks to me its trying to run query and show the results as a response.
ASKER CERTIFIED SOLUTION
bpmurray

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Musaab1

ASKER
Thanks a lot
This will help
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck