converting php to Java code trouble
<p>I am trying to write the following section of php code in java. I will provide the php code and the java code.  What I would like help with is a) am I even on the right track and b) the line with the "Please help here" comment, I am unsure of how to do this in java. This line is <code>header("Location: ".$strCitiRedirectURL.$content."");</code></p>

<p>Thank you in advance.</p>

<p>php code:</p>

<pre><code>$req =&amp; new HTTP_Request($strCitiLoginURL);
            $req-&gt;setMethod(HTTP_REQUEST_METHOD_POST);
            $req-&gt;addPostData("instusername", $strInstUsername);
            $req-&gt;addPostData("institution", $strInstitution);
            $req-&gt;addPostData("key", $strInstitutionKey);
            $req-&gt;addPostData("type", "returning");

            $response = $req-&gt;sendRequest();

            if(isset($_GET['showDebug'])){          
                print $req-&gt;_buildRequest(); 
            }

            if (PEAR::isError($response)) {
                $content = $response-&gt;getMessage();
            } else {
                $content = $req-&gt;getResponseBody();
            }

            /* Check for 44 Character UUID */
            if (preg_match($pattern,$content)){
                print 'Success';
                ob_start();
                header("Location: ".$strCitiRedirectURL.$content."");
                ob_flush();
            /* No UUID.  Login to CITI failed.  We may need a new user */
            }elseif ($content == "-  error: learner not affiliated with institution, add learner or provide username and password"){

                // Resubmit as a new user
                /* Package data up to post to CITI */
                $req =&amp; new HTTP_Request($strCitiLoginURL);
                $req-&gt;setMethod(HTTP_REQUEST_METHOD_POST);
                $req-&gt;addPostData("instusername", $strInstUsername);
                $req-&gt;addPostData("institution", $strInstitution);
                $req-&gt;addPostData("key", $strInstitutionKey);
                $req-&gt;addPostData("type", "new");
                $req-&gt;addPostData("first", $strFirst);
                $req-&gt;addPostData("last", $strLast);
                $req-&gt;addPostData("email", $strEmail);

                $response = $req-&gt;sendRequest();

                if(isset($_GET['showDebug'])){          
                    print $req-&gt;_buildRequest(); 
                }

                if (PEAR::isError($response)) {
                    $content = $response-&gt;getMessage();
                } else {
                    $content = $req-&gt;getResponseBody();
                }

                /* Check for 44 Character UUID */
                if (preg_match($pattern,$content)){
                    print 'Success';
                    ob_start();
            /*PLEASE HELP ON THIS LINE*/ header("Location: ".$strCitiRedirectURL.$content."");
                    ob_flush();
                }else{
                    $errMsg = $errMsg.' &lt;li&gt;CITI Error Returned: '.$content.'.&lt;/li&gt;';
                }
</code></pre>

<p>java code</p>

<pre><code>//****CITI CONFIGURATION****
            final String pattern = "([0-9A-\\-]{44})";
            final String CitiRedirectUrl = "https://www.citiprogram.org/members/mainmenu.asp?strKeyID=";
            final String CitiLoginUrl = "http://www.citiprogram.org/remoteloginII.asp";
            //****END CITI CONFIGURATION****

            try {
                // Construct data
                String data = URLEncoder.encode("instusername", "UTF-8") + "=" + URLEncoder.encode(c_form.getCan(), "UTF-8");
                data += "&amp;" + URLEncoder.encode("institution", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
                data += "&amp;" + URLEncoder.encode("key", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
                data += "&amp;" + URLEncoder.encode("type", "UTF-8") + "=" + URLEncoder.encode("returning", "UTF-8");

                // Send data
                URL url = new URL("http://www.citiprogram.org/remoteloginII.asp");
                URLConnection conn = url.openConnection();
                conn.setDoOutput(true);
                OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                wr.write(data);
                wr.flush();

                // Get the response
                BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String line;
                while ((line = rd.readLine()) != null) {
                    System.out.println(line);
                    if (pregMatch(pattern, line)) {
                        //Do the header part from the php code
                    } else if (line.equals("-  error: learner not affiliated with institution, add learner or provide username and password")) {
                        // Resubmit as a new user
            /* Package data up to post to CITI */

                        // Construct data
                        String newdata = URLEncoder.encode("instusername", "UTF-8") + "=" + URLEncoder.encode(c_form.getCan(), "UTF-8");
                        newdata += "&amp;" + URLEncoder.encode("institution", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
                        newdata += "&amp;" + URLEncoder.encode("key", "UTF-8") + "=" + URLEncoder.encode("value2", "UTF-8");
                        newdata += "&amp;" + URLEncoder.encode("type", "UTF-8") + "=" + URLEncoder.encode("returning", "UTF-8");

                        // Send data
                        OutputStreamWriter newwr = new OutputStreamWriter(conn.getOutputStream());
                        newwr.write(data);
                        newwr.flush();

                        // Get the response
                        BufferedReader newrd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        String newline;
                        while ((newline = newrd.readLine()) != null) {
                            System.out.println(newline);
                            if (pregMatch(pattern, newline)) {
                            } else {
                                //Print error message
                            }
                        }
                    }
                }
                wr.close();
                rd.close();
            } catch (Exception e) {
            }

//Check for 44 character UUID
    public static boolean pregMatch(String pattern, String content) {
        Pattern p = Pattern.compile(pattern);
        Matcher m = p.matcher(content);
        boolean b = m.matches();
        return b;
    }
</code></pre>
