troubleshooting Question

Code explanation

Avatar of Musaab1
Musaab1 asked on
Java
3 Comments1 Solution958 ViewsLast Modified:
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><%
            }
        %>
ASKER CERTIFIED SOLUTION
bpmurray

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros