I am working in a java web project in Eclipse IDE. project is working fine and we use Apache tomcat 7
as server. Now to access the application we use the URL as localhost:8080/APPNAME/
. It works fine.
In my project there is a servlet, that will request by other java file which is out side the eclipse. This java file make request to the servlet as localhost:8080/ServletName
.
Now what my instructor is telling is, all request can use 8080 port but for that particular servlet, he wants his own port number like localhost:4121/ServletName
. Is it possible ? If possible please tell me how .? I am new this kind of requirement. please tell me if there is a solution for this. It would be great help . thank you.
Find out which tomcat installation eclipse is using. Under your tomcat installation there is a conf/server.xml file. You add a new HTTP connector for the port you desire there and restart tomcat. Now you have tomcat listening to the extra port you added.
Now to 'bind' a specific servlet to a port like this, you would have to put some hack. There is no straight forward way other than to run two tomcat instances on separate ports. The hack could be based on this SO Post.