title: What happens when several Java servlet apps running on the same port?
body: <p>Something strange happened to my servlets and I think I've figured out why, yet I'm more confused. I used Netbean6.7 to develop a Paypal IPN (Instant Payment Notification) message servlet, it listens on port 8080 by default for Paypal IPN messages. I used some sample Java code from it's web site, but when it ran, only about 1 in 10 messages came through, and they looked correct, but why 1 in 10 ? Not 100% or none ? </p>
  
  <p>So I asked some questions here and got some advices, one in particular points me to Google's App Engine, so I downloaded it and ran the demo guestbook while my IPN servlet is still running on Netbeans, the strange thing happened, after I entered "appengine-java-sdk-1.3.2\bin\dev_appserver.cmd appengine-java-sdk-1.3.2\demos\guestbook\war" from the command prompt, I went to the following url on my browser "<a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a>", I thought I would see the Google demo guestbook page, NO, what I saw was another servlet I developed 2 years ago : "Web Academy", online course registration app. </p>
  
  <p>How can that happen? I never started it, and I haven't touch that project for years. I guess because it's also listening on port 8080, so now I understand why the IPN messages only came through 1 in 10 times, because another servlet was also listening on that port and could have got the messages intended for IPN, or some how those two servlets' processes mixed up and therefore couldn't respond to Paypal properly, and failed. In order to verify some of my guesses.</p>
  
  <p>I turn off Netbeans, and ran the Google guestbook again at the prompt, this time on my browser <a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a> points to the demo guestbook page.</p>
  
  <p>My Urls look like this :</p>
  
  <ul>
  <li>[A] Paypal IPN  : <a href="http://localhost:8080/PayPal_App/PayPal_Servlet" rel="nofollow noreferrer">http://localhost:8080/PayPal_App/PayPal_Servlet</a></li>
  <li>[B] Web Academy : <a href="http://localhost:8080/" rel="nofollow noreferrer">http://localhost:8080/</a></li>
  </ul>
  
  <p>So now, my questions are :</p>
  
  <ol>
  <li>Why the "Web Academy" servlet was auto started when I ran the Paypal servlet ?</li>
  <li>If I change the IPN listening port to 8083, would that mean I can run both of them on my PC at the same time without affecting each other ?</li>
  <li>But I still don't understand, [A] and [B] look different, if a page for [A] is refreshed, it should show the Paypal content, and another page looking at [B] should show the Web Academy content, and that's exactly what happens when I started Netbeans to run the Paypal servlet, both pages show their respective content correctly side by side without interfering with each other, how come the IPN messages couldn't get through 100% of the time ?</li>
  <li>In Netbeans how to assign 8080 to servlet [A] and assign port 8083 to servlet [B] ?</li>
  <li>How to turn off auto start of Web Academy by Netbeans ?</li>
  </ol>