Advertisement
naelah

Lab 5: common.jsp

Apr 20th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2.     pageEncoding="ISO-8859-1"%>
  3.     <%@ page import= "java.lang.*" %>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  5. <html>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  8. <title>Lab 5 part 2</title>
  9. </head>
  10. <body>
  11. <%
  12. String[] array1 = new String[]{request.getParameter("arr1.1") , request.getParameter("arr1.2") ,  request.getParameter("arr1.3") ,  request.getParameter("arr1.4") ,  request.getParameter("arr1.5") ,  request.getParameter("arr1.6") ,  request.getParameter("arr1.7") ,request.getParameter("arr1.8") , request.getParameter("arr1.9") ,  request.getParameter("arr1.9") };
  13. String[] array2 = new String[]{request.getParameter("arr2.1") , request.getParameter("arr2.2") , request.getParameter("arr2.3") ,  request.getParameter("arr2.4") ,  request.getParameter("arr2.5") ,  request.getParameter("arr2.6") ,  request.getParameter("arr2.7") ,  request.getParameter("arr2.8") ,  request.getParameter("arr2.9") ,  request.getParameter("arr2.9") };
  14. String[] com = new String[]{" "," "," ", " "," "," ", " "," "," "," " };
  15. %>
  16.  
  17. <%
  18. int k = 0, i=0; int j=0;
  19. while(array1[i].length() > 0 && i<9){
  20.      j=0;
  21.     breakme: while(array2[j].length()>0 && j<9){
  22. if (array1[i].equals(array2[j]))
  23. { com[k] =array1[i];
  24. k++;break breakme;}j++;}i++;}
  25.        
  26.  
  27. int icount = i; int jcount = 0;
  28. if(array1[i].equals(array2[j]))
  29. jcount = j+1 ;
  30. else
  31.     jcount = j;
  32. int kcount =k;
  33. %>
  34.  
  35. <table border=1>
  36. <tr><th>Array</th><th>List of the array</th><th>Common Elements</th></tr>
  37. <tr>
  38. <td>Array 1</td>
  39. <td><% for( i=0; i<icount;i++) {out.println(array1[i]);}%></td>
  40. <td rowspan=2 ><%for(k =0; k<kcount;k++) {out.println(com[k]);} %></td>
  41. </tr>
  42. <tr>
  43. <td>Array 2</td>
  44. <td><%for( j=0; j<jcount;j++){ out.println(array2[j]) ;}%></td>
  45. </tr>
  46. </table>
  47. </body>
  48. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement