Getting host, port and contextPath in the webapplication

I deploy my web app. on tomcat server. The web application that consists of servlets and jsps. I am also running a quartz cron job in my application that sends email once a day to some configured addresses. In the email, I need to provide a url to a web app resource. Because I'm building the url on the fly, I need to determine the servername/host, port and the application contextPath at runtime.
How can I get this information in the quartz job class?
thanks,

tcs wrote:
I understand that. My question was how do I get access to that info. from within the cron job (where there is no request object).You can only get that information for a specific request. It's possible to configure networks so that your container is serving requests for several different servers on several different ports, so asking for "the" host and "the" port is meaningless. Except in the context of a specific request, as I said.

Similar Messages

  • How to get the server port and id from the Initialcontext

    hi
    i know that i can get the server port and id where the jndi service is listening from the InitialContext ( when i create InitialContext ic = new InitialContext(); from within a EJB. ). Does this work on any application server and where (at what position is for example the port) in the Enumeration at the ic are the different things put?

    I would usually just get the PROVIDER_URL property from the InitialContext and use that to determine the location of the naming service:
    String providerURL = (String)ic.getEnvironment().get(Context.PROVIDER_URL);You'll then need to parse that string to obtain the port and the server name. For example:
    // Assume that the provider URL is of form "protocol://server:port"
    int serverStartIndex = providerURL.indexOf("://" + 3);
    int serverEndIndex = providerURL.indexOf(:, serverStartIndex);
    String server = providerURL.substring(serverStartIndex, serverEndIndex);
    String port = providerURL.substring(serverEndIndex + 1);It's a fairly universal approach but there'll doubtlessly be some special cases (for example, the provider URL could be null and the InitialContextFactory class defaults it).
    You might have to adjust the server/port parsing stuff a bit as I just made that up and your URL might not conform to the pattern I described.
    Hope this helps.

  • I have completely lost my safari.  I was getting an error and I lost the address bar.  I tried to fix it by changing the home page on the preferences.  I don't know what to put in the home page now.  How do I get safari back?

    I have completely lost my safari.  I was getting an error and I lost the address bar.  I tried to fix it by changing the home page on the preferences.  I don't know what to put in the home page now.  How do I get safari back?

    I tried editing my first post but couldn't get there...
    If you can open Safari go to the top of your screen, click Safari / Preferences then select the General stab. You can type in the web address for your Home page there.

  • When I try to restore my iPod touch 4G I get error 3194 and I have the latest version of iTunes

    When I try to restore my iPod touch 4G I get error 3194 and I have the latest version of iTunes

    Error 3194: Resolve error 3194 by updating to the latest version of iTunes. "This device is not eligible for the requested build" in the updater logs confirms this is the root of the issue. For more Error 3194 steps see: This device is not eligible for the requested build above.
    Are you trying to restore to a PC or an Mac?  Either way, I'd remove iTunes, empty the trash, restart, and download/install the latest version.  Also, check the versions of OS that the latest build of iTunes will work with.

  • The LCD for my macbook air model number MC965LL/A (purchased 2011) is broken , where  can I get new one and what is the part number for it ?

    The LCD for my macbook air model number MC965LL/A (purchased 2011) is broken , where  can I get new one and what is the part number for it ?

    You can find them at vendors like ifixit and instructions to install.
    http://www.ifixit.com/Mac-Parts/MacBook-Air-13%22-Mid-2011

  • Query for getting all function and procedure inside the packages

    hi All
    Please provide me Query for getting all function and procedure inside the packages
    thanks

    As Todd said, you can use user_arguments data dictionary or you can join user_objects and user_procedures like below to get the name of the packaged function and procedure names.
    If you are looking for the packaged procedures and functions source then use user_source data dictionary
    select a.object_name,a.procedure_name from user_procedures a,
                  user_objects b
    where a.object_name is not null
    and a.procedure_name is not null
    and b.object_type='PACKAGE'        
    and a.object_name=b.object_name

  • How to get customer number and name from the SD document

    Hi All,
    Can you please let me know how to get Customer Number and Name from the SD Document?
    Thanks a lot....
    Anil

    Hi,
    It will be displayed in the SD (BIlling document) itself,  you clikc on the VF03. The customer name and number will also appear in the SO document also Tcode VA03
    regards,
    radhika
    Edited by: kolipara radhika on Jul 10, 2009 5:32 AM

  • HT1752 MY IPOD HAS DIED AND APPLE WILL NO LONGER SERVICE IT. WHERE DO I GO TO GET IT SERVICED AND REPAIRED IN THE UK

    MY IPOD HAS DIED AND APPLE WILL NO LONGER SERVICE IT. WHERE DO I GO TO GET IT SERVICED AND REPAIRED IN THE UK

    Well first you locate your Caps Lock key. It is located above shift, and below tab. Now you press it, and take a deep breath. If your iPod is outside of its service, have you looked into other options like local repair shops? Sometimes they still service older products.
    -Alkaid

  • When I try to watch a video, the video gets all blurry and mixes with the other pages I'm using, and it doesn't stop throughout the video..what should I do?

    When I try to watch a video, the video gets all blurry and mixes with the other pages I'm using, and it doesn't stop throughout the video..what should I do?

    Hello Gemese,
    After reviewing your post, I have located an article that can help in this situation. It contains a number of troubleshooting steps and helpful advice concerning audio issues:
    iPhone: No sound or distorted sound from speaker
    http://support.apple.com/kb/ts5180
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • Getting host, port from the tnsnames.ora with the service name

    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.

    caesarkim wrote:
    Hi.
    I think that I asked a similar question yesterday. I want to ask if there is a way to get host and port from the tnsnames.org with a given service name. Somebody answered it for getting SID in the sqlplus. so I tried it in a similar way, but it didn't work.
    I have a service name, but I don't know how to get host and port. I know that I can parse the tnsnames.ora file to get it, but if possible, I want to use the more official and safe way.
    I'd appreciated if somebody knows it.Oracle RDBMS does not require SQL*Net to operate.
    Oracle RDBMS does NOT now or care about content of any tnsnames.ora file.
    Realize that each (remote) user can have their own personalized copy of tnsnames.ora
    The content of tnsnames not NOT have to reflect any reality.
    I could post the content of my tnsnames.ora & it would be useless to everyone reading.

  • Getting host name and port number from application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • Getting host name and port number from an application

    Does anyone know how I would be able to get the host name
    and port number from an application launched by java webstart ?
    This is the host and port of the URL that this application is launched from.

    A couple of suggestions:
    -The note is about 6.40. Doesn't fit for your server
    -Don't!
    -Reinstall!
    Regards,
    Benny

  • How to get Host name and port inside UDF

    Hi,
    I want to access the Host and port in UDF to pass it to a link http://host:port/AdapterFramework/ChannelAdminServlet?party=&service=&channel=*&action=status dynamically.
    How can I acieve it?
    Manisha

    Hi
    With this code. I am getting error:
    try
    java.net.InetAddress addr = java.net.InetAddress.getLocalHost();
    String host = addr.getCanonicalHostName();
    catch (UnknownHostException e){}
    if (ProcessMode.equals("P"))
    try{
    String xyz="/AdapterFramework/ChannelAdminServlet?party=&service=&channel="Name"&action=stop";
    URL server = new URL("http", host, 8XXX, xyz);
    tring userPassword =Userid + ":" + Password;
       String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
        URLConnection uc=server.openConnection();
        uc.setRequestProperty ("Authorization", "Basic " + encoding);
        BufferedReader br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
         while ((inputLine = br.readLine()) != null)
         output+=inputLine;
        br.close();
    catch (Exception e){}
    ERROR:
    cannot resolve symbol
    symbol : variable host location: class com.sap.xi.tf._MM_CommunicationChannel_Stop
    _ URL server = new URL("http", host, 8xxx, xyz);
    ^ 1 error
    Any other way to get host and port?
    Manisha

  • Smart View not working in Hyperion 9.3.3 (Getting Host/Port Error (500))

    When i m trying to connect smart view , i Get the following Error Message . Cannot Connect to the Provider . Make sure its running in the specified host/port . Error (500) . I have tried the following at my end . Restarted the IIS and Web Servcies . I need to resolve the issue as soon as possible . Kindly Help .

    Hi this is the Detailed error Message I got when I try to run hfmofficeprivder.aspx
    Exception Details: System.Web.HttpException: The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:
    [HttpException (0x80004005): The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.]
    System.Web.HttpRuntime.SetUpCodegenDirectory(CompilationSection compilationSection) +3474107
    System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags) +226
    [HttpException (0x80004005): The current identity (NT AUTHORITY\NETWORK SERVICE) does not have write access to 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files'.]
    System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +3426839
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +88
    System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +149
    Regards,
    David
    Edited by: David Mallela on May 24, 2012 8:04 PM

  • Getting host name and IP address

    I have develop different types of forms which resides on server and clients are acessing it.Now from my end i want to track that which user is accessing my forms on the server i.e i want to know the client IP address and host name.When the user execute some query on the database then i will get it easily using sys_context function but if it perform some functions within the form and i catch the host name then it returns the server host name where the actual forms resides not the client host name and i want to know the client host name and IP address who is running the forms.Plz let me know the way so i can do that easily .
    thanks

    Hi Grant,
    I want to get ip/address host name of reports server, sitting on forms server.
    can you tell me how to do this.
    in a web base environment.
    i have several report server instances running on different machines.
    when i run a report using RUN_REPORT_OBJECT using report_server=mac_rep1
    i want to know mac_rep1 resides on which host/ip machine.
    regds

Maybe you are looking for