Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 802823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:39:47+00:00 2026-05-14T23:39:47+00:00

I have a Java servlet running on my notebook with Windows Vista, I set

  • 0

I have a Java servlet running on my notebook with Windows Vista, I set up a static IP, did port forwarding and registered for a free DDNS service, now my servlet is running, I gave the url to Paypal to send me IPN messages, I went on to it’s sandbox site got to the test tools page, tried to send test messages by clicking the “Send IPN” button, most of the time it would fail, the error is : “IPN delivery failed. Unable to connect to the specified URL. Please verify the URL and try again.”

But maybe 1 in 10 times, it might be successful and my servlet would get the message, and I looked at the messages I got, they are in correct format. So I called Paypal asking why, he said I shouldn’t run the servlet on my notebook, in stead I should run it on the web server, but I told him my ISP doesn’t support Java on their server, and since I did all the above steps, shouldn’t it be the same to run the servlet on my notebook ? He said his test showed he couldn’t get to my servlet, but I asked why maybe 1 in 10 times it could get through ? If there is something wrong with running it on my notebook, then 100% times it should fail, am I correct on this point ? But anyway he said that’s all he could do, and I should troubleshoot it myself. The servlet looks like this :

import java.io.*;
import java.net.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;

public class PayPal_Servlet extends HttpServlet
{
  static boolean Debug=true;
  static String PayPal_Url="https://www.paypal.com/cgi-bin/webscr",Sandbox_Url="https://www.sandbox.paypal.com/cgi-bin/webscr",
                Dir_License_Messages="C:/Dir_License_Messages/";
  static TransparencyExample Transparency_Example;
  static PayPal_Message_To_License_File_Worker PayPal_message_to_license_file_worker;
  // Initializes the servlet.
  public void init(ServletConfig config) throws ServletException
  {
    super.init(config);
    if (!new File(Dir_License_Messages).exists()) new File(Dir_License_Messages).mkdirs();
    System.gc();
  }

  /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
   * @param request servlet request
   * @param response servlet response
   */
  protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
  {
    // Read post from PayPal system and add 'cmd'
    Enumeration en=request.getParameterNames();
    String str="cmd=_notify-validate";

    while (en.hasMoreElements())
    {
      String paramName=(String)en.nextElement();
      String paramValue=request.getParameter(paramName);
      str=str+"&"+paramName+"="+URLEncoder.encode(paramValue);
    }

    //  Post back to PayPal system to validate
    //  NOTE: change http: to https: in the following URL to verify using SSL (for increased security).
    //  using HTTPS requires either Java 1.4 or greater, or Java Secure Socket Extension (JSSE) and configured for older versions.
    URL u=new URL(Debug?Sandbox_Url:PayPal_Url);
    URLConnection uc=u.openConnection();
    uc.setDoOutput(true);
    uc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    PrintWriter pw=new PrintWriter(uc.getOutputStream());
    pw.println(str);
    pw.close();

    BufferedReader in=new BufferedReader(new InputStreamReader(uc.getInputStream()));
    String res=in.readLine();
    in.close();

    // Assign posted variables to local variables
    String itemName=request.getParameter("item_name");
    String itemNumber=request.getParameter("item_number");
    String paymentStatus=request.getParameter("payment_status");
    String paymentAmount=request.getParameter("mc_gross");
    String paymentCurrency=request.getParameter("mc_currency");
    String txnId=request.getParameter("txn_id");
    String receiverEmail=request.getParameter("receiver_email");
    String payerEmail=request.getParameter("payer_email");

    if (res.equals("VERIFIED"))        // Check notification validation
    {
      // check that paymentStatus=Completed
      // check that txnId has not been previously processed
      // check that receiverEmail is your Primary PayPal email
      // check that paymentAmount/paymentCurrency are correct
      // process payment
    }
    else if (res.equals("INVALID"))    // Log for investigation
    {

    }
    else                               // Log for error
    {

    }
// ===========================================================================
    if (txnId!=null)
    {
      Write_File_Safe_Fast(Dir_License_Messages+txnId+".txt",new StringBuffer(str.replace("&","\n")),false);
    }

// ===========================================================================
    String Message_File_List[]=Tool_Lib.Get_File_List_From_Dir(Dir_License_Messages);
    response.setContentType("text/html");
    PrintWriter out=response.getWriter();
    String title="Reading All Request Parameters",Name="",Value;
    out.println("<Html><Head><Title>"+title+"</Title></Head>\n<Body Bgcolor=\"#FDF5E6\">\n<H1 Align=Center>"+title+"</H1>\n"+
                "<Table Border=1 Align=Center>\n"+"<Tr Bgcolor=\"#FFAD00\"><Th>Parameter Name</Th><Th>Parameter Value(s)   Messages = "+Message_File_List.length+"</Th></Tr>");
    Enumeration paramNames=request.getParameterNames();
    while(paramNames.hasMoreElements())
    {
      String paramName=(String)paramNames.nextElement();
      out.print("<Tr><Td>"+paramName+"</Td><Td>");
      String[] paramValues=request.getParameterValues(paramName);
      if (paramValues.length == 1)
      {
        String paramValue=paramValues[0];
        if (paramValue.length() == 0) out.print("<I>No Value</I>");
        else
        {
          out.println(paramValue+"</Td></Tr>");
//          Out("paramName = "+paramName+"  paramValue = "+paramValue);
//          if (paramName.startsWith("Name")) Name=paramValue;
//          else if (paramName.startsWith("Value")) Write_File_Safe_Fast("C:/Dir_Data/"+Name,new StringBuffer(paramValue),false);
        }
      }
      else
      {
        out.println("<Ul>");
        for (int i=0;i<paramValues.length;i++) out.println("<Li>"+paramValues[i]);
        out.println("</Ul></Td</Tr>");
      }
    }
    out.println("</Table>\n</Body></Html>");
  }

  /** Handles the HTTP <code>GET</code> method.
   * @param request servlet request
   * @param response servlet response
   */
  protected void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { processRequest(request,response); }

  /** Handles the HTTP <code>POST</code> method.
   * @param request servlet request
   * @param response servlet response
   */
  protected void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { processRequest(request,response); }

  // Returns a short description of the servlet.
  public String getServletInfo() { return "Short description"; }

  // Destroys the servlet.
  public void destroy() { System.gc(); }

  public static void Write_File_Safe_Fast(String File_Path,StringBuffer Str_Buf,boolean Append)
  {
    FileOutputStream fos=null;
    BufferedOutputStream bos=null;

    try
    {
      fos=new FileOutputStream(File_Path,Append);
      bos=new BufferedOutputStream(fos);
      for (int j=0;j<Str_Buf.length();j++) bos.write(Str_Buf.charAt(j));
    }
    catch (Exception e) { e.printStackTrace(); }
    finally
    {
      try 
      {
        if (bos!=null)
        {
          bos.close();
          bos=null;
        }
        if (fos!=null)
        {
          fos.close();
          fos=null;
        }
      }
      catch (Exception ex) { ex.printStackTrace(); }
    }
    System.gc();
  }
}

I use Netbean6.7 to develop the servlet, and the code was from Paypal’s JSP sample code, what can I do to debug the problem ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:39:47+00:00Added an answer on May 14, 2026 at 11:39 pm

    HI, try to use my library:
    http://paypal-nvp.sourceforge.net/index.htm
    I hope it will help you. If you have any questions, improvements you can contact me. You find my email in the comments of the source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 401k
  • Answers 401k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Pick yourself up a copy of Martin Fowler's Refactoring. It… May 15, 2026 at 4:26 am
  • Editorial Team
    Editorial Team added an answer I'm having trouble understanding the purpose of writing such code.… May 15, 2026 at 4:26 am
  • Editorial Team
    Editorial Team added an answer Thanks for those who have visited. After 2 days trying… May 15, 2026 at 4:26 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.