1

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.

1 Answer 1

2

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.

<Connector port="4121" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" 
           URIEncoding="UTF-8" />

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.

Sign up to request clarification or add additional context in comments.

4 Comments

can we do it in Eclipse.
Editing server.xml? It can be done using any editor. By the way do you know where your server.xml is ?
Yes I know . . Wht I am asking is , by adding the above line in serve.xml , can I make request using both the ports?
also you might wanna see this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.