Results 1 to 7 of 7
  1. #1
    Donky is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default How to show tomcat website on a different httpListener/Thread

    Hi,

    I'm creating a java-web project inside tomcat. (Tomcas starts a servlet that starts a counter application pased on GPIO states). In there is a web-interface that is showing the counter and some other informaition. On the web interface there is also a configuration form where the client can set some names/backupintervall/counterDelay etc...

    Only i run tomcat on a port 8045. Setting up by the tomcat xml. But what i want is a second port threat that listen to a port (given by properties file like: webport-second=4302). That threat must show the same information that i get from tomcat port 8045. Like a redirection to that port but without browser redirect.

    Is that possible and how must i do that?

  2. #2
    jashburn is offline Senior Member
    Join Date
    Feb 2014
    Posts
    219
    Rep Power
    1

    Default Re: How to show tomcat website on a different httpListener/Thread

    You should be able to do so by adding another <connector> to your server.xml.

  3. #3
    Donky is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default Re: How to show tomcat website on a different httpListener/Thread

    Ye that's when i want to do it in tomcat but i don't want to do that in tomcat. I create a option on my webpage to reload that second thread so i can reload it to the new port without restarting tomcat. so server.xml is not possible for me.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,149
    Rep Power
    6

    Default Re: How to show tomcat website on a different httpListener/Thread

    Your problem description is entirely vague to me. It sounds like you want a socket server to magically pop up and start listening on your server when you only configure a number in your client.

    Try explaining the purpose of this "second thread". Why do you need two things producing exactly the same thing and why must one of them be on a dynamic port?
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  5. #5
    Donky is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default Re: How to show tomcat website on a different httpListener/Thread

    Quote Originally Posted by gimbal2 View Post
    Your problem description is entirely vague to me. It sounds like you want a socket server to magically pop up and start listening on your server when you only configure a number in your client.

    Try explaining the purpose of this "second thread". Why do you need two things producing exactly the same thing and why must one of them be on a dynamic port?
    Okey what i have is a tomcat listen to port 8045 that shows a website (website a).

    Now i want a second server/httpListener on a different port. (Not running by tomcat) that loads the same content as tomcat (website a).

    Why do i want that?
    In my application there is a web-interface where users can change the web-port when they want that. Only i will not let them change the server.xml or restart the hole application. Thats why i want that second listener/thread so i can stop/run that thread without restarting the hole tomcat server.

    Why i don't want to restart the tomcat?
    Tomcat starts a servlet that starts 4 threats on startup that reads some linux GPIO inputs (hardware) that must keep running all the time. No tomcat restart allowed while that threats are running. When i try that i will get errors because the linux GPIO are already in use than. That GPIO's has a shutdown script required before i can use them again. So thats why i want that second listener

    Why i called a threat?
    I'm new to java (doing this for 2/3 weeks now) maby i misnamed this. Thats why i asked this in the forum (New to Java). Sorry

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,149
    Rep Power
    6

    Default Re: How to show tomcat website on a different httpListener/Thread

    Yes well I can't give any real advice here, I think you're entirely barking up the wrong tree and the fact that you're too new to this does not help. Let me take a stab at it anyway.

    One has to not marry to a technical solution like you are doing but rather strive for a correct architecture; in my opinion your architecture is flawed. In your scenario, the tomcat server should not be starting up threads; that is "something else" which you communicate with from your tomcat server. When you make your web server not be responsible for the uptime of your GPIO inputs and you have more flexibility to bring it down. Separation of concerns is very important to maintain system stability; right now if some web action makes your Tomcat server go loopy your highly important GPIO inputs will also be influenced.

    As to "web port", I can only assume you mean the port that the web server is listening on; so for example you don't want to connect to http://blabla.com:8080 but to http://blabla.com:<someotherport>. Probably you will need some HTTPD server in front of your Tomcat server to make the port numbers more flexible, but I must admit that my knowledge of such server management configuration is limited. I'm also not up to speed with what Tomcat 8 can do, but the documentation should be able to tell you what is and isn't possible.
    Last edited by gimbal2; 05-24-2014 at 12:00 AM.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Donky is offline Member
    Join Date
    May 2014
    Posts
    4
    Rep Power
    0

    Default Re: How to show tomcat website on a different httpListener/Thread

    @gimbal2
    Thanks for your advice. I will go look for a way to separate my GPIO threats from tomcat and can still share some memory data. Than i can restart tomcat without any problems. thanks.

Similar Threads

  1. Replies: 4
    Last Post: 07-02-2011, 04:28 AM
  2. Replies: 2
    Last Post: 06-08-2011, 05:19 PM
  3. Replies: 4
    Last Post: 05-08-2011, 10:00 PM
  4. set up tomcat on website
    By hunterbdb in forum Java Servlet
    Replies: 1
    Last Post: 04-22-2009, 07:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •