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 ?
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 “http://localhost:8080/“, 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.
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.
I turn off Netbeans, and ran the Google guestbook again at the prompt, this time on my browser http://localhost:8080/ points to the demo guestbook page.
My Urls look like this :
- [A] Paypal IPN : http://localhost:8080/PayPal_App/PayPal_Servlet
- [B] Web Academy : http://localhost:8080/
So now, my questions are :
- Why the “Web Academy” servlet was auto started when I ran the Paypal servlet ?
- 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 ?
- 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 ?
- In Netbeans how to assign 8080 to servlet [A] and assign port 8083 to servlet [B] ?
- How to turn off auto start of Web Academy by Netbeans ?
There are so much things questions mixed in your question that I don’t know where to start. What is sure is that you need to go back to the basics and to take some time to understand how things work. Servlets are pieces of code packaged inside a web application which is deployed in a servlet container (a server). Let’s look at how you access them:
Where:
.warextension but a webapp can be mapped to “/” aka the root context).Now, let’s try to answer your questions:
My guess is that this old application is still deployed on the server you’re using under NetBeans (maybe NetBeans built-in server). So when you “start” the new application (and actually the server), the old one is also accessible.
As we saw, this doesn’t make sense, a server is listening to a port, not a servlet.
The URL [A] points to the PayPal_Servlet of the PayPal_App. The URL [B] points to the default page of a web application mapped to the root context. In other words, both URLs points to different applications.
Sorry to repeat that but this doesn’t make sense. You can very likely change the port used by the server started in NetBeans but, still, both servlets would be served by the same server, running on a new port.
I’m not sure but do some clean up in the directory where applications are deployed (with tomcat, check the
webappsdirectory) or in theserver.xml. Hard to say without more details on your configuration, on what you installed, etc.