hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Chow <eric...@gmail.com>
Subject Re: Post parameter arrays !!
Date Thu, 20 Jan 2005 01:15:44 GMT
Any idea on the following form, it just return the status code 302 !!!
The following is the HTML form and my code:




<HTML>
<HEAD>
<LINK REL=STYLESHEET TYPE="text/css" HREF="css/cdbs.css">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset='MS950'">
<META HTTP-EQUIV="paragma" CONTENT="no-cache">
<META HTTP-EQUIV="expires" CONTENT="-1">
<title>SC Online Booking System - New Booking Form (Step 1 of 3: Input
Booking Details)</title>
</HEAD>
<body style="font-size: 10pt; font-family: Arial" bgcolor="#FFFFFF"
text="#000000" topmargin="0" onLoad="init();">

<script language="JavaScript" src="script/common_script.js">
</script>
<script language="JavaScript">
 C_ITEM_NO = 5;
 C_BOOKING_HOUR_LIMIT = 3;
 function check_input() {
   i = 0;
   fillCnt = 0;
   loopCnt = C_ITEM_NO - 1;
   isPrevItemEmptyFlag = false;
   isItemValidFlag = false;
   while (i <= loopCnt) {
     isItemEmptyFlag = check_item_empty(i);
     if (isItemEmptyFlag == false) {
       if (isPrevItemEmptyFlag == true) {
         alert("Please fill in your booking items in sequential order.");
         document.bform.wv_booking_date[i-1].focus();
         return false;
       }
       isItemValidFlag = check_item(i);
       if (isItemValidFlag == false) {
         return false;
       }
     isItemDuplicated = check_item_duplication(i);
     if (isItemDuplicated == true) {
       return false;
     }

       isBookingHourOverLimit = check_item_hour_over_limit(i);
       if (isBookingHourOverLimit == true) {
       return false;
       }

       fillCnt++;
     }
     if (document.bform.chk_booking_light[i].checked) {
       document.bform.wv_booking_light[i].value = "Y";
     } else {
       document.bform.wv_booking_light[i].value = "N";
     }
     if (document.bform.chk_booking_air[i].checked) {
       document.bform.wv_booking_air[i].value = "Y";
     } else {
       document.bform.wv_booking_air[i].value = "N";
     }
     isPrevItemEmptyFlag = (isItemEmptyFlag == true)?true:false;
     i++;
   }
//    alert("fillCnt: " + fillCnt);
   if (parseInt(fillCnt) == 0) {
         alert("Please fill in at least one activity.");
     document.bform.wv_booking_date[0].focus();
     return false;
   }
   return true;
 }

 function FromTimeChange(i)
 {
   document.bform.wv_booking_time_to[i].options.selectedIndex =
   document.bform.wv_booking_time_from[i].options.selectedIndex
   return true;
 }

 function check_facility_existence (i) {
 if (document.bform.wv_booking_place[i].options.selectedIndex == 0) {
   document.bform.chk_booking_light[i].disabled=false;
   document.bform.chk_booking_air[i].disabled=false;
 }
 if (trim(document.bform.wv_booking_place[i].value) == 'SQ1') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'T1') {
   document.bform.chk_booking_light[i].disabled=false;
   document.bform.chk_booking_air[i].disabled=true;
   document.bform.chk_booking_air[i].checked=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'T2') {
   document.bform.chk_booking_light[i].disabled=false;
   document.bform.chk_booking_air[i].disabled=true;
   document.bform.chk_booking_air[i].checked=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'ZDR') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'SQ2') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'PAV') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'ZS1') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=true;
   document.bform.chk_booking_air[i].checked=false;
}
 if (trim(document.bform.wv_booking_place[i].value) == 'ZS2') {
   document.bform.chk_booking_light[i].disabled=true;
   document.bform.chk_booking_light[i].checked=false;
   document.bform.chk_booking_air[i].disabled=true;
   document.bform.chk_booking_air[i].checked=false;
}
}

 function check_item(i) {
     if ( document.bform.wv_booking_date[i].options.selectedIndex == 0)
     {
       alert("The booking date is invalid");
       document.bform.wv_booking_date[i].focus();  return false;
     }
     if ( document.bform.wv_booking_place[i].options.selectedIndex == 0)
     {
       alert("The booking place is empty");
       document.bform.wv_booking_place[i].focus();  return false;
     }
     v_facilities = trim(document.bform.wv_booking_facilities[i].value);
     if (trim(document.bform.wv_booking_place[i].value) == 'PAV') {
       if (v_facilities.length == 0) {
         alert("Please specify the facilities for using the complex
Pavilion, e.g. soccer, " +
               "basketball, volleyball, badminton, table tennis or
handball,etc");
         document.bform.wv_booking_facilities[i].focus(); return false;
       }
     }
     if ( document.bform.wv_booking_time_from[i].options.selectedIndex == 0)
     {
       alert("The booking time (FROM) is empty");
       document.bform.wv_booking_time_from[i].focus(); return false;
     }
     if ( document.bform.wv_booking_time_to[i].options.selectedIndex == 0)
     {
       alert("The booking time (TO) is empty");
       document.bform.wv_booking_time_to[i].focus(); return false;
     }
     if ( parseInt(document.bform.wv_booking_time_from[i].options.value)
            >=
          parseInt(document.bform.wv_booking_time_to[i].options.value) )
     {
       alert("Booking time (TO) should be greater than booking time (FROM)");
       document.bform.wv_booking_time_to[i].focus(); return false;
     }
     return true;
 }

 function check_item_empty(i) {
   v_booking_facilities = trim(document.bform.wv_booking_facilities[i].value);
   if ((document.bform.wv_booking_date[i].options.selectedIndex == 0) &&
        (document.bform.wv_booking_place[i].options.selectedIndex == 0) &&
        (document.bform.wv_booking_time_from[i].options.selectedIndex == 0) &&
        (document.bform.wv_booking_time_to[i].options.selectedIndex == 0) &&
        (!document.bform.chk_booking_light[i].checked) &&
        (!document.bform.chk_booking_air[i].checked) &&
        (v_booking_facilities.length == 0)) {
       return true;
   } else {
     return false;
   }
 }

 function check_item_duplication(i) {
   v_booking_date = trim(document.bform.wv_booking_date[i].value);
   v_booking_place = trim(document.bform.wv_booking_place[i].value);
   v_booking_time_from = trim(document.bform.wv_booking_time_from[i].value);
   v_booking_time_to = trim(document.bform.wv_booking_time_to[i].value);
   for (j = 0; j < i; j++) {
     v_temp_booking_date = trim(document.bform.wv_booking_date[j].value);
     v_temp_booking_place = trim(document.bform.wv_booking_place[j].value);
     v_temp_booking_time_from =
trim(document.bform.wv_booking_time_from[j].value);
     v_temp_booking_time_to = trim(document.bform.wv_booking_time_to[j].value);
     if ((v_booking_date == v_temp_booking_date) && (v_booking_place
== v_temp_booking_place)) {
       if (parseInt(v_booking_time_from) >=
parseInt(v_temp_booking_time_from) &&
           parseInt(v_booking_time_from) < parseInt(v_temp_booking_time_to)) {
         alert("Booking time (FROM) of booking item " + (parseInt(i) + 1) +
               " overlaps with booking item " + (parseInt(j)+ 1) + ".");
         document.bform.wv_booking_time_from[i].focus();
         return true;
       }
       if (parseInt(v_booking_time_to) > parseInt(v_temp_booking_time_from) &&
           parseInt(v_booking_time_to) <= parseInt(v_temp_booking_time_to)) {
         alert("Booking time (TO) of booking item " + (parseInt(i) + 1) +
               " overlaps with booking item " + (parseInt(j)+ 1) + ".");
         document.bform.wv_booking_time_to[i].focus();
         return true;
       }
       if (parseInt(v_booking_time_from) <
parseInt(v_temp_booking_time_from) &&
           parseInt(v_booking_time_to) > parseInt(v_temp_booking_time_to)) {
         alert("The booking time span of booking item " + (parseInt(i) + 1) +
               " overlaps with booking item " + (parseInt(j)+ 1) + ".");
         document.bform.wv_booking_time_from[i].focus();
         return true;
       }
     }
   }
   return false;
 }

 function check_item_hour_over_limit(i) {

   v_booking_date = trim(document.bform.wv_booking_date[i].value);
   v_booking_time_from = trim(document.bform.wv_booking_time_from[i].value);
   v_booking_time_to = trim(document.bform.wv_booking_time_to[i].value);
   v_booking_time_duration = parseInt(v_booking_time_to) -
parseInt(v_booking_time_from);
   v_tot_booking_time_duration = 0;
   for (j = 0; j <= i; j++) {
     v_temp_booking_date = trim(document.bform.wv_booking_date[j].value);
     if (v_booking_date == v_temp_booking_date) {
       v_temp_booking_time_from =
trim(document.bform.wv_booking_time_from[j].value);
       v_temp_booking_time_to =
trim(document.bform.wv_booking_time_to[j].value);
       v_temp_booking_time_duration =
parseInt(v_temp_booking_time_to) - parseInt(v_temp_booking_time_from);
       v_tot_booking_time_duration += v_temp_booking_time_duration;
       if (parseInt(v_tot_booking_time_duration) >
parseInt(C_BOOKING_HOUR_LIMIT)) {
       alert("To achieve fair allocation for CDUM facilities, " +
             "you are only allowed to book maximum " +
C_BOOKING_HOUR_LIMIT + " hours for any complexes in a day. " +
             "However, you intended to book " +
v_tot_booking_time_duration + " hours on the date " + v_booking_date +
". " +
             "For details, please refer to the regulations listed in
the Booking Instruction.");
       document.bform.wv_booking_date[i].focus();
       return true;
     }
    }
  }
  return false;
 }

 function clear_booking_item(i) {
       document.bform.wv_booking_date[i].options.selectedIndex = 0;
       document.bform.wv_booking_place[i].options.selectedIndex = 0;
       document.bform.wv_booking_time_from[i].options.selectedIndex = 0;
       document.bform.wv_booking_time_to[i].options.selectedIndex =0;
       document.bform.chk_booking_light[i].checked = false;
       document.bform.chk_booking_air[i].checked = false;
       document.bform.wv_booking_facilities[i].value = "";
 document.bform.chk_booking_light[i].disabled=false;
 document.bform.chk_booking_air[i].disabled=false;
 }

function popup_input_form(i) {
       isValid = true;
       if (document.bform.wv_booking_date[i].options.selectedIndex == 0)
       {
               alert("To use this function, please select Booking Date
and Booking
Place first.");
               document.bform.wv_booking_date[i].focus();
               isValid = false;
       }
       if (isValid) {
               if (
document.bform.wv_booking_place[i].options.selectedIndex == 0)
               {
               alert("To use this function, please fill in Booking
Date and Booking
Place first.");
               document.bform.wv_booking_place[i].focus();
               isValid = false;
               }
               if (isValid) {
                       sURL = "CDW234_WebBookingNewDtlInput.jsp?";
                       sURL += "wv_CheckDate=" +
trim(document.bform.wv_booking_date[i].value);
                       sURL += "&wv_CheckPlace=" +
trim(document.bform.wv_booking_place[i].value);
                       sURL += "&wv_item_index=" + i;
                      
TimetableEnqResultwin=window.open(sURL,'TimetableEnqResult',"width=630,
height=200, resize=no");
               }
       }
}

function init() {
       // Check Facility existence
       for (var i=0; i < C_ITEM_NO; i++) {
               if
(document.bform.wv_booking_place[i].options.selectedIndex != 0) {
                       check_facility_existence(i);
               }
       }
}

</script>
<form onSubmit="return check_input()" method="post" name="bform"
     action="CDW230_WebBookingNewServlet" >
 <b><font size="4" face="Arial, Helvetica, sans-serif"> </font></b>
 <input type="hidden" name="submitKey" value="0.9467773532451136">
 <table width="560" border="0" cellspacing="0" cellpadding="0" height="5%">
   <tr>
     <td valign="top" height="25"><b><font size="4" face="Arial,
Helvetica, sans-serif">Step
       1 of 3: New Booking - Input Booking Details</font></b></td>
   </tr>
 </table>
 <b><font size="4" face="Arial, Helvetica, sans-serif">

 </font></b>
 <table width="560" border="1" bgcolor="#FFFFFF"
bordercolor="#CCCCCC" height="58%" >
   <tr>
     <td>
       <table width="560" border="0" style="font-family: Arial;
font-size: 10pt" cellpadding="2" cellspacing="2" bordercolor="#666699"
height="100%" >
         <tr>
           <td colspan=4 height="20" bgcolor="#666999"><b><font
color="#FFFFFF">
             User Info</font></b></td>
         </tr>
         <tr>
           <td>
             <table border=0 style="font-family: Arial; font-size:
10pt" width="560" height="100%">
               <tr valign="middle">
                 <td height="15" width="90"><b>User ID :</b></td>
                 <td height="15" width="81">MA162139</td>
                 <td height="15" width="55"><b>Name :</b></td>
                 <td height="15" width="411">CHAO HOI KA</td>
               </tr>
               <tr valign="middle">
                 <td width="90" height="15"><b>User Type :</b></td>
                 <td width="81" height="15">STUDENT</td>
                 <td width="55" height="15"><b>Tel :</b></td>
                 <td width="411" height="15">222877, 533977, 6665272</td>
               </tr>
             </table>
           </td>
         </tr>
         <tr>
           <td bgcolor="#666699" height="20"><b><font
color="#FFFFFF">Activities</font></b></td>
         </tr>
         <tr>
           <td height="53">
             <table border=0 style="font-family: Arial; font-size:
10pt" width="560" height="100%">
               <tr>
                 <td valign="top" width="65"><b>Date<font
color="#FF9900">*</font></b></td>
                 <td valign="top" width="68"><b>Place<font
color="#FF9900">*</font></b></td>
                 <td valign="top" width="41"><b>From<font
color="#FF9900">*</font></b></td>
                 <td valign="top" width="33"><b>To<font
color="#FF9900">*</font></b></td>
                 <td valign="top" align=center width="40"><b>Light</b></td>
                 <td valign="top" align=center width="36"><b>A/C</b></td>
                 <td valign="top" width="112"><b>Facilities</b></td>
                 <td valign="top" width="38"></td>
                 <td valign="top" width="51"></td>
                 <td valign="top" width="34">&nbsp;</td>
               </tr>

               <tr>
                 <td width="65" height="25"><select
name=wv_booking_date class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='18/01/2005' >18/01/2005(TUE)</option>
<option value='19/01/2005' >19/01/2005(WED)</option>
<option value='20/01/2005' >20/01/2005(THU)</option>
<option value='21/01/2005' >21/01/2005(FRI)</option>
<option value='22/01/2005' >22/01/2005(SAT)</option>
<option value='23/01/2005' >23/01/2005(SUN)</option>
<option value='24/01/2005' >24/01/2005(MON)</option>
<option value='25/01/2005' >25/01/2005(TUE)</option>
<option value='26/01/2005' >26/01/2005(WED)</option>
<option value='27/01/2005' >27/01/2005(THU)</option>
<option value='28/01/2005' >28/01/2005(FRI)</option>
<option value='29/01/2005' >29/01/2005(SAT)</option>
<option value='30/01/2005' >30/01/2005(SUN)</option>
<option value='31/01/2005' >31/01/2005(MON)</option>
<option value='01/02/2005' >01/02/2005(TUE)</option>
</select>
</td>
                 <td width="68" height="25"><select
name=wv_booking_place
onChange='javascript:check_facility_existence(0);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value = 'SQ1' >SQUASH 1</option>
<option value = 'T1' >TENNIS 1</option>
<option value = 'T2' >TENNIS 2</option>
<option value = 'ZDR' >DANCE-ROOM</option>
<option value = 'SQ2' >SQUASH 2</option>
<option value = 'PAV' >PAVILION</option>
<option value = 'ZS1' >SAUNA 1</option>
<option value = 'ZS2' >SAUNA 2</option>
</select>
</td>
                 <td width="41" height="25"><select
name=wv_booking_time_from onChange='javascript:FromTimeChange(0);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='8' >8:00</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
</select>
</td>
                 <td width="33" height="25"><select
name=wv_booking_time_to null class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
<option value='22' >22:00</option>
</select>
</td>
                 <td align=center width="40" height="25">
                   <input type="hidden" name=wv_booking_light value="">
                   <input type="checkbox" name=chk_booking_light  >
                 </td>
                 <td align=center width="36" height="25">
                   <input type="hidden" name=wv_booking_air value="">
                   <input type="checkbox" name=chk_booking_air  >
                 </td>
                 <td width="112" height="25">
                   <input type="text" name="wv_booking_facilities"
size=12 value="" maxlength="20" class='clsInputCourierText'>
                 </td>
                 <td width="38" height="25">
                   <div align="center"> <img
src="images/calendar.gif" width="18" height="18"
onclick="javascript:popup_input_form(0);" alt="Click to query booking
availability and select booking hour" >
                   </div>
                 </td>
                   <td width="51" height="25">
                   <input type="button" value="Clear" name="btnClear"
onClick="clear_booking_item(0)">
                 </td>
                 <td width="34" height="25">

                 </td>
               </tr>

               <tr>
                 <td width="65" height="25"><select
name=wv_booking_date class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='18/01/2005' >18/01/2005(TUE)</option>
<option value='19/01/2005' >19/01/2005(WED)</option>
<option value='20/01/2005' >20/01/2005(THU)</option>
<option value='21/01/2005' >21/01/2005(FRI)</option>
<option value='22/01/2005' >22/01/2005(SAT)</option>
<option value='23/01/2005' >23/01/2005(SUN)</option>
<option value='24/01/2005' >24/01/2005(MON)</option>
<option value='25/01/2005' >25/01/2005(TUE)</option>
<option value='26/01/2005' >26/01/2005(WED)</option>
<option value='27/01/2005' >27/01/2005(THU)</option>
<option value='28/01/2005' >28/01/2005(FRI)</option>
<option value='29/01/2005' >29/01/2005(SAT)</option>
<option value='30/01/2005' >30/01/2005(SUN)</option>
<option value='31/01/2005' >31/01/2005(MON)</option>
<option value='01/02/2005' >01/02/2005(TUE)</option>
</select>
</td>
                 <td width="68" height="25"><select
name=wv_booking_place
onChange='javascript:check_facility_existence(1);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value = 'SQ1' >SQUASH 1</option>
<option value = 'T1' >TENNIS 1</option>
<option value = 'T2' >TENNIS 2</option>
<option value = 'ZDR' >DANCE-ROOM</option>
<option value = 'SQ2' >SQUASH 2</option>
<option value = 'PAV' >PAVILION</option>
<option value = 'ZS1' >SAUNA 1</option>
<option value = 'ZS2' >SAUNA 2</option>
</select>
</td>
                 <td width="41" height="25"><select
name=wv_booking_time_from onChange='javascript:FromTimeChange(1);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='8' >8:00</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
</select>
</td>
                 <td width="33" height="25"><select
name=wv_booking_time_to null class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
<option value='22' >22:00</option>
</select>
</td>
                 <td align=center width="40" height="25">
                   <input type="hidden" name=wv_booking_light value="">
                   <input type="checkbox" name=chk_booking_light  >
                 </td>
                 <td align=center width="36" height="25">
                   <input type="hidden" name=wv_booking_air value="">
                   <input type="checkbox" name=chk_booking_air  >
                 </td>
                 <td width="112" height="25">
                   <input type="text" name="wv_booking_facilities"
size=12 value="" maxlength="20" class='clsInputCourierText'>
                 </td>
                 <td width="38" height="25">
                   <div align="center"> <img
src="images/calendar.gif" width="18" height="18"
onclick="javascript:popup_input_form(1);" alt="Click to query booking
availability and select booking hour" >
                   </div>
                 </td>
                   <td width="51" height="25">
                   <input type="button" value="Clear" name="btnClear"
onClick="clear_booking_item(1)">
                 </td>
                 <td width="34" height="25">

                 </td>
               </tr>

               <tr>
                 <td width="65" height="25"><select
name=wv_booking_date class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='18/01/2005' >18/01/2005(TUE)</option>
<option value='19/01/2005' >19/01/2005(WED)</option>
<option value='20/01/2005' >20/01/2005(THU)</option>
<option value='21/01/2005' >21/01/2005(FRI)</option>
<option value='22/01/2005' >22/01/2005(SAT)</option>
<option value='23/01/2005' >23/01/2005(SUN)</option>
<option value='24/01/2005' >24/01/2005(MON)</option>
<option value='25/01/2005' >25/01/2005(TUE)</option>
<option value='26/01/2005' >26/01/2005(WED)</option>
<option value='27/01/2005' >27/01/2005(THU)</option>
<option value='28/01/2005' >28/01/2005(FRI)</option>
<option value='29/01/2005' >29/01/2005(SAT)</option>
<option value='30/01/2005' >30/01/2005(SUN)</option>
<option value='31/01/2005' >31/01/2005(MON)</option>
<option value='01/02/2005' >01/02/2005(TUE)</option>
</select>
</td>
                 <td width="68" height="25"><select
name=wv_booking_place
onChange='javascript:check_facility_existence(2);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value = 'SQ1' >SQUASH 1</option>
<option value = 'T1' >TENNIS 1</option>
<option value = 'T2' >TENNIS 2</option>
<option value = 'ZDR' >DANCE-ROOM</option>
<option value = 'SQ2' >SQUASH 2</option>
<option value = 'PAV' >PAVILION</option>
<option value = 'ZS1' >SAUNA 1</option>
<option value = 'ZS2' >SAUNA 2</option>
</select>
</td>
                 <td width="41" height="25"><select
name=wv_booking_time_from onChange='javascript:FromTimeChange(2);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='8' >8:00</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
</select>
</td>
                 <td width="33" height="25"><select
name=wv_booking_time_to null class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
<option value='22' >22:00</option>
</select>
</td>
                 <td align=center width="40" height="25">
                   <input type="hidden" name=wv_booking_light value="">
                   <input type="checkbox" name=chk_booking_light  >
                 </td>
                 <td align=center width="36" height="25">
                   <input type="hidden" name=wv_booking_air value="">
                   <input type="checkbox" name=chk_booking_air  >
                 </td>
                 <td width="112" height="25">
                   <input type="text" name="wv_booking_facilities"
size=12 value="" maxlength="20" class='clsInputCourierText'>
                 </td>
                 <td width="38" height="25">
                   <div align="center"> <img
src="images/calendar.gif" width="18" height="18"
onclick="javascript:popup_input_form(2);" alt="Click to query booking
availability and select booking hour" >
                   </div>
                 </td>
                   <td width="51" height="25">
                   <input type="button" value="Clear" name="btnClear"
onClick="clear_booking_item(2)">
                 </td>
                 <td width="34" height="25">

                 </td>
               </tr>

               <tr>
                 <td width="65" height="25"><select
name=wv_booking_date class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='18/01/2005' >18/01/2005(TUE)</option>
<option value='19/01/2005' >19/01/2005(WED)</option>
<option value='20/01/2005' >20/01/2005(THU)</option>
<option value='21/01/2005' >21/01/2005(FRI)</option>
<option value='22/01/2005' >22/01/2005(SAT)</option>
<option value='23/01/2005' >23/01/2005(SUN)</option>
<option value='24/01/2005' >24/01/2005(MON)</option>
<option value='25/01/2005' >25/01/2005(TUE)</option>
<option value='26/01/2005' >26/01/2005(WED)</option>
<option value='27/01/2005' >27/01/2005(THU)</option>
<option value='28/01/2005' >28/01/2005(FRI)</option>
<option value='29/01/2005' >29/01/2005(SAT)</option>
<option value='30/01/2005' >30/01/2005(SUN)</option>
<option value='31/01/2005' >31/01/2005(MON)</option>
<option value='01/02/2005' >01/02/2005(TUE)</option>
</select>
</td>
                 <td width="68" height="25"><select
name=wv_booking_place
onChange='javascript:check_facility_existence(3);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value = 'SQ1' >SQUASH 1</option>
<option value = 'T1' >TENNIS 1</option>
<option value = 'T2' >TENNIS 2</option>
<option value = 'ZDR' >DANCE-ROOM</option>
<option value = 'SQ2' >SQUASH 2</option>
<option value = 'PAV' >PAVILION</option>
<option value = 'ZS1' >SAUNA 1</option>
<option value = 'ZS2' >SAUNA 2</option>
</select>
</td>
                 <td width="41" height="25"><select
name=wv_booking_time_from onChange='javascript:FromTimeChange(3);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='8' >8:00</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
</select>
</td>
                 <td width="33" height="25"><select
name=wv_booking_time_to null class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
<option value='22' >22:00</option>
</select>
</td>
                 <td align=center width="40" height="25">
                   <input type="hidden" name=wv_booking_light value="">
                   <input type="checkbox" name=chk_booking_light  >
                 </td>
                 <td align=center width="36" height="25">
                   <input type="hidden" name=wv_booking_air value="">
                   <input type="checkbox" name=chk_booking_air  >
                 </td>
                 <td width="112" height="25">
                   <input type="text" name="wv_booking_facilities"
size=12 value="" maxlength="20" class='clsInputCourierText'>
                 </td>
                 <td width="38" height="25">
                   <div align="center"> <img
src="images/calendar.gif" width="18" height="18"
onclick="javascript:popup_input_form(3);" alt="Click to query booking
availability and select booking hour" >
                   </div>
                 </td>
                   <td width="51" height="25">
                   <input type="button" value="Clear" name="btnClear"
onClick="clear_booking_item(3)">
                 </td>
                 <td width="34" height="25">

                 </td>
               </tr>

               <tr>
                 <td width="65" height="25"><select
name=wv_booking_date class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='18/01/2005' >18/01/2005(TUE)</option>
<option value='19/01/2005' >19/01/2005(WED)</option>
<option value='20/01/2005' >20/01/2005(THU)</option>
<option value='21/01/2005' >21/01/2005(FRI)</option>
<option value='22/01/2005' >22/01/2005(SAT)</option>
<option value='23/01/2005' >23/01/2005(SUN)</option>
<option value='24/01/2005' >24/01/2005(MON)</option>
<option value='25/01/2005' >25/01/2005(TUE)</option>
<option value='26/01/2005' >26/01/2005(WED)</option>
<option value='27/01/2005' >27/01/2005(THU)</option>
<option value='28/01/2005' >28/01/2005(FRI)</option>
<option value='29/01/2005' >29/01/2005(SAT)</option>
<option value='30/01/2005' >30/01/2005(SUN)</option>
<option value='31/01/2005' >31/01/2005(MON)</option>
<option value='01/02/2005' >01/02/2005(TUE)</option>
</select>
</td>
                 <td width="68" height="25"><select
name=wv_booking_place
onChange='javascript:check_facility_existence(4);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value = 'SQ1' >SQUASH 1</option>
<option value = 'T1' >TENNIS 1</option>
<option value = 'T2' >TENNIS 2</option>
<option value = 'ZDR' >DANCE-ROOM</option>
<option value = 'SQ2' >SQUASH 2</option>
<option value = 'PAV' >PAVILION</option>
<option value = 'ZS1' >SAUNA 1</option>
<option value = 'ZS2' >SAUNA 2</option>
</select>
</td>
                 <td width="41" height="25"><select
name=wv_booking_time_from onChange='javascript:FromTimeChange(4);'
class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='8' >8:00</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
</select>
</td>
                 <td width="33" height="25"><select
name=wv_booking_time_to null class='clsInputCourierText'>
<option value = '' selected>--</option>
<option value='9' >9:00</option>
<option value='10' >10:00</option>
<option value='11' >11:00</option>
<option value='12' >12:00</option>
<option value='13' >13:00</option>
<option value='14' >14:00</option>
<option value='15' >15:00</option>
<option value='16' >16:00</option>
<option value='17' >17:00</option>
<option value='18' >18:00</option>
<option value='19' >19:00</option>
<option value='20' >20:00</option>
<option value='21' >21:00</option>
<option value='22' >22:00</option>
</select>
</td>
                 <td align=center width="40" height="25">
                   <input type="hidden" name=wv_booking_light value="">
                   <input type="checkbox" name=chk_booking_light  >
                 </td>
                 <td align=center width="36" height="25">
                   <input type="hidden" name=wv_booking_air value="">
                   <input type="checkbox" name=chk_booking_air  >
                 </td>
                 <td width="112" height="25">
                   <input type="text" name="wv_booking_facilities"
size=12 value="" maxlength="20" class='clsInputCourierText'>
                 </td>
                 <td width="38" height="25">
                   <div align="center"> <img
src="images/calendar.gif" width="18" height="18"
onclick="javascript:popup_input_form(4);" alt="Click to query booking
availability and select booking hour" >
                   </div>
                 </td>
                   <td width="51" height="25">
                   <input type="button" value="Clear" name="btnClear"
onClick="clear_booking_item(4)">
                 </td>
                 <td width="34" height="25">

                 </td>
               </tr>

             </table>
           </td>
         </tr>
         <tr>
           <td valign="top">
               <table width="100%" border="0" cellspacing="1" cellpadding="1">
                 <tr>
                   <td>
                     <input type="reset" value="Clear All" name="reset">
                     <input type="submit" value="Calculate Booking
Fee" name="submit">
                     <font size="1" color="#CC0000"><b></b></font></td>

                 <td>
                   <div align="center"><font size="1"
color="#CC0000"><b><font color="#FF9900" face="Arial, Helvetica,
sans-serif" size="2">*</font><font color="#333333" face="Arial,
Helvetica, sans-serif">
                     = required information</font></b></font></div>
                 </td>
                 </tr>
               </table>
           </td>
         </tr>
         <tr>
           <td valign="middle" height="20" bgcolor="#666699"> <font
color="#6666FF">
             <font color="#666999"> <b> <font color="#FFFFCC">

             Current balance of your OPA account: &nbsp;$&nbsp;243

             </font> </b> </font> </font> </td>
         </tr>
       </table>
     </td>
   </tr>
 </table>
<table width='560'  valign='bottom' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td align='left'><font size='-1'>[<a
href="javascript:win=open('CDW206_TermsOfUse.html',
'BookingInstruction',
'width=590,height=300,location=no,toolbar=no,status=no,resizable=no,scrollbars=yes');win.focus();">Terms
of Use</a>]</font>
<font size='-1'>[<a href='CDW202_Content.html'>Go To Main</a>]</font>
</td><td align='right'><font size='-1'><a
href="javascript:win=open('CDW205_BookingInstruction.html',
'BookingInstruction',
'width=600,height=300,location=no,toolbar=no,status=no,resizable=no,scrollbars=yes');win.focus();"><img
border=0 align=absmiddle src='images/help.gif' alt='Booking
Instruction'>&nbsp;Booking Instruction</a></font>
</td></tr>
</table>

</form>

</BODY>
</HTML>

package my;

import java.io.*;
import java.util.regex.*;

import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.methods.*;

public class Booking
{
   static final String LOGON_SITE = "isw.umac.mo";
   static final int    LOGON_PORT = 443;

   public Booking() {
       super();
   }

       public static void main(String[] args) throws Exception {

               HttpClient client = new HttpClient();
               client.getHostConfiguration().setHost(LOGON_SITE,
LOGON_PORT, "https");
               client.getState().setCookiePolicy(CookiePolicy.COMPATIBILITY);

       login(client);

               book(client);

               //balance(client);

               logout(client);

       }

       private static void book(HttpClient client) throws Exception {
               System.out.println("Booking: ");
               GetMethod bookGet = new
GetMethod("/cdweb/CDW230_WebBookingNew.jsp");
               client.executeMethod(bookGet);

               InputStream is = bookGet.getResponseBodyAsStream();
               BufferedReader br = new BufferedReader(new InputStreamReader(is,
"ISO-8859-1"));

               String regex = "name=\"submitKey\" value=\"*.*\"";
               Pattern compiledRegex = Pattern.compile(regex, 0);

               String resp = null;

               String submitKey = null;

               while((resp = br.readLine()) != null) {
                       Matcher regexMatcher = compiledRegex.matcher(resp);

                       //System.out.println(resp);

                       if (regexMatcher.find()) {
                               /*
                               if (regexMatcher.groupCount() > 0) {
                                       // Capturing parenthesis are
numbered 1..groupCount()
                                       // group number zero is the
entire regex match

                                       for (int i = 1; i <=
regexMatcher.groupCount(); i++) {
                                               String groupLabel = new
String("Group " + Integer.toString(i));

                                               if (regexMatcher.start(i) < 0) {
                                                      
System.out.println(groupLabel + " did not participate in the
overall match\n");
                                               } else {
                                                      
System.out.println(groupLabel + " start: " +
Integer.toString(regexMatcher.start(i)) + "\n");
                                                      
System.out.println(groupLabel + " end: " +
Integer.toString(regexMatcher.end(i)) + "\n");
                                                      
System.out.println(groupLabel + " length: " +
Integer.toString(regexMatcher.end(i) - regexMatcher.start(i)) + "\n");

                                                       String val =
regexMatcher.group(i);
                                                      
System.out.println(groupLabel + " matched text: " + val + "\n");
                                                      
System.out.println("Exactlty value: " + val.substring(1));
                                               }
                                       }
                               }
                               */

                               String[] x =
resp.split("name=\"submitKey\" value=\"");

                               String []y = x[1].split("\"");
                               submitKey = y[0];

                               System.out.println("Submit key: " + submitKey);

                               break;
                       }
               }

               bookGet.releaseConnection();

               PostMethod bookPost = new
PostMethod("/cdweb/CDW230_WebBookingNewServlet");
               // Prepare login parameters
               NameValuePair skey   = new NameValuePair("submitKey", submitKey);
               NameValuePair bDate = new
NameValuePair("wv_booking_date", "23/01/2005");
               NameValuePair bPlace = new
NameValuePair("wv_booking_place", "SQ1");
               NameValuePair bTimeFrom = new
NameValuePair("wv_booking_time_from", "21");
               NameValuePair bTimeTo = new
NameValuePair("wv_booking_time_to", "22");
               NameValuePair bLight = new
NameValuePair("wv_booking_light", "Y");
               NameValuePair bCLight = new
NameValuePair("chk_booking_light", "yes");
               NameValuePair bAir = new NameValuePair("wv_booking_air", "Y");
               NameValuePair bCAir = new
NameValuePair("chk_booking_air", "yes");
               NameValuePair bFac = new
NameValuePair("wv_booking_facilities", "s");

               NameValuePair bDate1 = new
NameValuePair("wv_booking_date", null);
               NameValuePair bPlace1 = new
NameValuePair("wv_booking_place", null);
               NameValuePair bTimeFrom1 = new
NameValuePair("wv_booking_time_from", null);
               NameValuePair bTimeTo1 = new
NameValuePair("wv_booking_time_to", null);
               NameValuePair bLight1 = new
NameValuePair("wv_booking_light", "N");
               NameValuePair bCLight1 = new
NameValuePair("chk_booking_light", "no");
               NameValuePair bAir1 = new NameValuePair("wv_booking_air", "N");
               NameValuePair bCAir1 = new
NameValuePair("chk_booking_air", "no");
               NameValuePair bFac1 = new
NameValuePair("wv_booking_facilities", null);

               NameValuePair bDate2 = new
NameValuePair("wv_booking_date", null);
               NameValuePair bPlace2 = new
NameValuePair("wv_booking_place", null);
               NameValuePair bTimeFrom2 = new
NameValuePair("wv_booking_time_from", null);
               NameValuePair bTimeTo2 = new
NameValuePair("wv_booking_time_to", null);
               NameValuePair bLight2 = new
NameValuePair("wv_booking_light", "N");
               NameValuePair bCLight2 = new
NameValuePair("chk_booking_light", "no");
               NameValuePair bAir2 = new NameValuePair("wv_booking_air", "N");
               NameValuePair bCAir2 = new
NameValuePair("chk_booking_air", "no");
               NameValuePair bFac2 = new
NameValuePair("wv_booking_facilities", null);

               NameValuePair bDate3 = new
NameValuePair("wv_booking_date", null);
               NameValuePair bPlace3 = new
NameValuePair("wv_booking_place", null);
               NameValuePair bTimeFrom3 = new
NameValuePair("wv_booking_time_from", null);
               NameValuePair bTimeTo3 = new
NameValuePair("wv_booking_time_to", null);
               NameValuePair bLight3 = new
NameValuePair("wv_booking_light", "N");
               NameValuePair bCLight3 = new
NameValuePair("chk_booking_light", "no");
               NameValuePair bAir3 = new NameValuePair("wv_booking_air", "N");
               NameValuePair bCAir3 = new
NameValuePair("chk_booking_air", "no");
               NameValuePair bFac3 = new
NameValuePair("wv_booking_facilities", null);

               NameValuePair bDate4 = new
NameValuePair("wv_booking_date", null);
               NameValuePair bPlace4 = new
NameValuePair("wv_booking_place", null);
               NameValuePair bTimeFrom4 = new
NameValuePair("wv_booking_time_from", null);
               NameValuePair bTimeTo4 = new
NameValuePair("wv_booking_time_to", null);
               NameValuePair bLight4 = new
NameValuePair("wv_booking_light", "N");
               NameValuePair bCLight4 = new
NameValuePair("chk_booking_light", "no");
               NameValuePair bAir4 = new NameValuePair("wv_booking_air", "N");
               NameValuePair bCAir4 = new
NameValuePair("chk_booking_air", "no");
               NameValuePair bFac4 = new
NameValuePair("wv_booking_facilities", null);

               bookPost.setRequestBody(
                               new NameValuePair[] {
                                               skey, bDate, bPlace,
bTimeFrom, bTimeTo, bLight, bCLight, bAir,
bCAir, bFac,
                                               bDate1, bPlace1,
bTimeFrom1, bTimeTo1, bLight1, bCLight1, bAir1,
bCAir1, bFac1,
                                               bDate2, bPlace2,
bTimeFrom2, bTimeTo2, bLight2, bCLight2, bAir2,
bCAir2, bFac2,
                                               bDate3, bPlace3,
bTimeFrom3, bTimeTo3, bLight3, bCLight3, bAir3,
bCAir3, bFac3,
                                               bDate4, bPlace4,
bTimeFrom4, bTimeTo4, bLight4, bCLight4, bAir4,
bCAir4, bFac4,
                                                                      
        } );

               client.executeMethod(bookPost);

               System.out.println(bookPost.getResponseBodyAsString());

               bookPost.releaseConnection();

               Cookie[] bookcookies =
               client.getState().getCookies(LOGON_SITE, LOGON_PORT,
"/cdweb", false);
               System.out.println("Booking cookies:");

               if (bookcookies.length == 0) {
                       System.out.println("None");
               } else {
                       for (int i = 0; i < bookcookies.length; i++) {
                               System.out.println("- " +
bookcookies[i].toString());
                       }
               }

               // Usually a successful form-based login results in a
redicrect to
               // another url
               int statuscode = bookPost.getStatusCode();

               if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY) ||
                       (statuscode == HttpStatus.SC_MOVED_PERMANENTLY) ||
                       (statuscode == HttpStatus.SC_SEE_OTHER) ||
                       (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) {

                       Header header = bookPost.getResponseHeader("location");

                       if (header != null) {
                               String newuri = header.getValue();

                               if ((newuri == null) || (newuri.equals(""))) {
                                       newuri = "/";
                               }

                               System.out.println("Redirect target: " + newuri);
                               GetMethod redirect = new GetMethod(newuri);

                               client.executeMethod(redirect);
                               System.out.println("Redirect: " +
redirect.getStatusLine().toString());
                               // release any connection resources
used by the method
                               redirect.releaseConnection();
                       } else {
                               System.out.println("Invalid redirect");
                               System.exit(1);
                       }
               } // if
       }

       private static void balance(HttpClient client) throws Exception {
               // query balance
               System.out.println("Balance: ");
               GetMethod balanceGet = new
GetMethod("/cdweb/CDW260_OpaBalanceEnq.jsp");
               client.executeMethod(balanceGet);
               String resp = balanceGet.getResponseBodyAsString();

               System.out.println("-----------------------------------");
               System.out.println(resp);
               System.out.println("-----------------------------------");
               System.out.println("Login form get: " +
balanceGet.getStatusLine().toString());
               // release any connection resources used by the method
               balanceGet.releaseConnection();
       }

       private static void login(HttpClient client) throws Exception {

               // 'developer.java.sun.com' has cookie compliance problems
               // Their session cookie's domain attribute is in
violation of the RFC2109
               // We have to resort to using compatibility cookie policy

               GetMethod authget = new GetMethod("/cdweb/CDW210_Login.jsp");

               client.executeMethod(authget);
               System.out.println("Login form get: " +
authget.getStatusLine().toString());
               // release any connection resources used by the method
               authget.releaseConnection();
               // See if we got any cookies
               Cookie[] initcookies =
               client.getState().getCookies(LOGON_SITE, LOGON_PORT,
"/cdweb", false);
               System.out.println("Initial set of cookies:");

               if (initcookies.length == 0) {
                       System.out.println("None");
               } else {
                       for (int i = 0; i < initcookies.length; i++) {
                               System.out.println("- " +
initcookies[i].toString());
                       }
               }

               PostMethod authpost = new
PostMethod("/cdweb/CDW210_LoginServlet");
               // Prepare login parameters
               NameValuePair userid   = new
NameValuePair("wv_user_id", "MY_USER_ID");
               NameValuePair password = new
NameValuePair("wv_user_password", "MY_PASSWORD");
               authpost.setRequestBody( new NameValuePair[] {userid, password});

               client.executeMethod(authpost);
               System.out.println("Login form post: " +
authpost.getStatusLine().toString());
               // release any connection resources used by the method
               authpost.releaseConnection();
               // See if we got any cookies
               // The only way of telling whether logon succeeded is
               // by finding a session cookie
               Cookie[] logoncookies =
               client.getState().getCookies(LOGON_SITE, LOGON_PORT,
"/cdweb", false);
               System.out.println("Logon cookies:");

               if (logoncookies.length == 0) {
                       System.out.println("None");
               } else {
                       for (int i = 0; i < logoncookies.length; i++) {
                               System.out.println("- " +
logoncookies[i].toString());
                       }
               }

               // Usually a successful form-based login results in a
redicrect to
               // another url
               int statuscode = authpost.getStatusCode();

               if ((statuscode == HttpStatus.SC_MOVED_TEMPORARILY) ||
                       (statuscode == HttpStatus.SC_MOVED_PERMANENTLY) ||
                       (statuscode == HttpStatus.SC_SEE_OTHER) ||
                       (statuscode == HttpStatus.SC_TEMPORARY_REDIRECT)) {

                       Header header = authpost.getResponseHeader("location");

                       if (header != null) {
                               String newuri = header.getValue();

                               if ((newuri == null) || (newuri.equals(""))) {
                                       newuri = "/";
                               }

                               System.out.println("Redirect target: " + newuri);
                               GetMethod redirect = new GetMethod(newuri);

                               client.executeMethod(redirect);
                               System.out.println("Redirect: " +
redirect.getStatusLine().toString());
                               // release any connection resources
used by the method
                               redirect.releaseConnection();
                       } else {
                               System.out.println("Invalid redirect");
                               System.exit(1);
                       }
               } // if

       }

       private static void logout(HttpClient client) throws Exception {
               // logout
               System.out.println("Logout: ");
               GetMethod logoutGet = new GetMethod("/cdweb/CDW250_Logout.jsp");
               client.executeMethod(logoutGet);
               System.out.println("Login form get: " +
logoutGet.getStatusLine().toString());
               // release any connection resources used by the method
               logoutGet.releaseConnection();
  }
}







On Wed, 19 Jan 2005 10:05:06 -0800, Julius Davies
<juliusdavies@cucbc.com> wrote:
> Whoops!  Meant to say:
> 
> method.setRequestHeader()
> 
> yours,
> 
> Julius
> 
> On Wed, 2005-19-01 at 14:35 +0800, Eric Chow wrote:
> > Hi Julius,
> >
> > I can't get any setHeader() method in PostMethod !
> > How can I add the header ??
> >
> > Eric
> >
> >
> >
> >
> >
> > On Tue, 18 Jan 2005 18:15:22 -0800, Julius Davies
> > <juliusdavies@cucbc.com> wrote:
> > > Hi, Eric,
> > >
> > > In an earlier post I recommend using Mozilla + LiveHttpHeaders plugin to watch exactly what the browser does.  In this example, the browser's request looks like:
> > >
> > > =====================================
> > > POST /servlet/mypost HTTP/1.1
> > > Content-Type: application/x-www-form-urlencoded
> > > Content-Length: 17
> > > key=a&key=b&key=c
> > >
> > > =====================================
> > >
> > > Does that give you an idea?  Don't forget to add this to your code!
> > >
> > > method.setHeader( "content-type", "application/x-www-form-urlencoded" );
> > >
> > > yours,
> > >
> > > Julius
> > >
> > >
> > > -----Original Message-----
> > > From:   Eric Chow [mailto:eric138@gmail.com]
> > > Sent:   Mon 1/17/2005 8:15 PM
> > > To:     httpclient-user@jakarta.apache.org
> > > Cc:
> > > Subject:        Post parameter arrays !!
> > > Hello,
> > >
> > > How can I post an array of parameters ?
> > >
> > > For example,
> > >
> > > <form action="/servlet/mypost" method="post">
> > >   <input type=text name="key">
> > >   <input type=text name="key">
> > >  <input type=text name="key">
> > > </form>
> > >
> > > As in the above HTML form, there are three text field with the same name "key",
> > > how can I post this kind of form with HttpClient ??
> > >
> > > Eric
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
> > >
> > >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Mime
View raw message