Please HELP..! to translate php codes to java... PLEASE..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • angelyn
    New Member
    • Feb 2008
    • 3

    Please HELP..! to translate php codes to java... PLEASE..

    i'm having problem with these matter.. can you please give me exact translated code of this to java...


    <?php
    if ($_GET['doretrieve'] == "atr")
    {
    $handle = fopen("http://www.bsp.gov.ph/keyrates.asp"," r");
    $contents = '';
    while (!feof($handle) )
    {
    $contents .= fread($handle, 8192);
    }
    fclose($handle) ;

    $date_mark = "<div align=\"center\ " class=\"style1\ ">";
    $contents_date = substr($content s,strpos($conte nts,$date_mark) +strlen($date_m ark),20);
    $variables_date = explode("<",$co ntents_date);

    $contents_val = substr($content s,strpos($conte nts,"PhP"),12);

    $variables_val = explode("<",$co ntents_val);
    $variables_val[0] = str_replace("Ph P","",$variable s_val[0]);

    echo "&var_date= " . trim($variables _date[0]);
    echo "&var_php=" . trim($variables _val[0]);
    }
    ?>
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by angelyn
    i'm having problem with these matter.. can you please give me exact translated code of this to java...


    <?php
    if ($_GET['doretrieve'] == "atr")
    {
    $handle = fopen("http://www.bsp.gov.ph/keyrates.asp"," r");
    $contents = '';
    while (!feof($handle) )
    {
    $contents .= fread($handle, 8192);
    }
    fclose($handle) ;

    $date_mark = "<div align=\"center\ " class=\"style1\ ">";
    $contents_date = substr($content s,strpos($conte nts,$date_mark) +strlen($date_m ark),20);
    $variables_date = explode("<",$co ntents_date);

    $contents_val = substr($content s,strpos($conte nts,"PhP"),12);

    $variables_val = explode("<",$co ntents_val);
    $variables_val[0] = str_replace("Ph P","",$variable s_val[0]);

    echo "&var_date= " . trim($variables _date[0]);
    echo "&var_php=" . trim($variables _val[0]);
    }
    ?>
    There's no such thing as exact translated code. You want to have that code logic in a JSP? Have you worked with Java or PHP before?

    Comment

    • BigDaddyLH
      Recognized Expert Top Contributor
      • Dec 2007
      • 1216

      #3
      I've never seen PHP before. Euw...

      Comment

      • angelyn
        New Member
        • Feb 2008
        • 3

        #4
        Originally posted by r035198x
        There's no such thing as exact translated code. You want to have that code logic in a JSP? Have you worked with Java or PHP before?

        ok. if that so can you give me or provide me a code logic in jsp..? please... i have worked with java before but only its fundamentals but i know i can do it if you'll provide me code logic of it... and please be there to guide me.. thanks!

        Comment

        • BigDaddyLH
          Recognized Expert Top Contributor
          • Dec 2007
          • 1216

          #5
          Originally posted by angelyn
          ok. if that so can you give me or provide me a code logic in jsp..? please... i have worked with java before but only its fundamentals but i know i can do it if you'll provide me code logic of it... and please be there to guide me.. thanks!
          We don't hand out solutions, but if you post the requirements of your problem, we can give you a few hints.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by angelyn
            ok. if that so can you give me or provide me a code logic in jsp..? please... i have worked with java before but only its fundamentals but i know i can do it if you'll provide me code logic of it... and please be there to guide me.. thanks!
            For starters, you'll need to replace the $_GET part with request.getPara meter and also replace the fopen with a combination of FileReader and BufferedReader( look them up).
            Generally though, it's wise to separate your Java (processing) code from your HTML (display) code. Perhaps you should read the file in some utility class ...

            Comment

            Working...