Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7CB4911A16 for ; Tue, 19 Aug 2014 16:54:52 +0000 (UTC) Received: (qmail 2642 invoked by uid 500); 19 Aug 2014 16:54:40 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 2567 invoked by uid 500); 19 Aug 2014 16:54:39 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 2556 invoked by uid 99); 19 Aug 2014 16:54:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Aug 2014 16:54:39 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of rajacassian@gmail.com designates 209.85.220.175 as permitted sender) Received: from [209.85.220.175] (HELO mail-vc0-f175.google.com) (209.85.220.175) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Aug 2014 16:54:35 +0000 Received: by mail-vc0-f175.google.com with SMTP id ik5so7599096vcb.6 for ; Tue, 19 Aug 2014 09:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=arMnkAuEEFYBKYV5fMCbmOFjMg5dYa6W0kM8cseEuX4=; b=yM5lY44iiY5iuyZ809/EzmjvZ7CHneojM4EUIAuaDVRNihyMh8xDlmkamCxoCg60TM oe2EFNZ00fCJqV8EsB9xHPUV9PymO2hIPx9EQwBAvYVORxDQDV2Bu5cq6f8wsHpD4awM p5iyRDzYSOPKEvIjpF32QCuZjY+4aebMeSiGo9yMPNwv4imzwavmmzv/e7stbsWPa5Iq LSO7X0s0Z/y3sH44jcd9pc3e0ZsBCJ195XA+uOy6t8OObS1birBlNyp1Cpp3sJGCDSwB ipjSCLLsseY4B2HuaW9Cz5d/TVerLQV8LPMiAPtdAPOglih071oIWCnv+Hdg9tdpmQg9 NZyA== MIME-Version: 1.0 X-Received: by 10.220.187.134 with SMTP id cw6mr658851vcb.71.1408467254661; Tue, 19 Aug 2014 09:54:14 -0700 (PDT) Received: by 10.221.8.197 with HTTP; Tue, 19 Aug 2014 09:54:14 -0700 (PDT) In-Reply-To: <53F34332.8070207@verizon.net> References: <53F2F36D.4060307@ice-sa.com> <53F34332.8070207@verizon.net> Date: Tue, 19 Aug 2014 22:24:14 +0530 Message-ID: Subject: Re: How to get the configured HTTP and HTTPS port numbers in server.xml from Java code at runtime From: Cassian Raja Thomas To: Tomcat Users List Content-Type: multipart/alternative; boundary=089e01537c1e64582d0500fe5690 X-Virus-Checked: Checked by ClamAV on apache.org --089e01537c1e64582d0500fe5690 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yeah.. Now I got it. Thanks for the information On Tue, Aug 19, 2014 at 5:59 PM, David kerber wrote: > On 8/19/2014 4:36 AM, Cassian Raja Thomas wrote: > >> I can retrieve the information prior to getting the connection refused >> message and then compare the port numbers with the one sent in the reque= st >> parameters. Thereby, I can handle the exception and throw it with nice >> error code and message >> > > Not from the server side, you can't. Connection refusal is done at the > operating system and tcp/ip stack level. If the OS refuses the connectio= n, > it will never get to your tomcat server or any other service you have > running on it. You might be able to do this on the client side with > javascript, though. > > > > >> >> On Tue, Aug 19, 2014 at 12:19 PM, Andr=C3=A9 Warnier wro= te: >> >> Cassian Raja Thomas wrote: >>> >>> In our project, we have implemented SOAP webservices using Apache CXF >>>> framework. Clients used to request the server for some command >>>> execution. >>>> The request consists of host, port and the protocol used for connectio= n. >>>> If >>>> the client uses a HTTPS configured port number and specify the protoco= l >>>> as >>>> HTTP, then we get a connection refused - socket exception as expected. >>>> But, >>>> I need to throw a proper error message like "Unable to connect to host >>>> "XYZ" with port "ABC" using http protocol". For this, I need to get th= e >>>> configured http and https port numbers from tomcat server.xml file at >>>> runtime and then compare it with my request parameters. >>>> >>>> Anyone, please help me out on how to do that? >>>> >>>> >>>> I think that you are chasing windmills (attemting something >>> impossible), >>> because if the connection is refused, the Tomcat code itself probably >>> never >>> even sees this. >>> The "connection refused" message is coming from your own client's TCP/I= P >>> stack. >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org >>> For additional commands, e-mail: users-help@tomcat.apache.org >>> >>> >>> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --089e01537c1e64582d0500fe5690--