tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Grzegorz Borkowski <grzegorzborkow...@o2.pl>
Subject Re: running! a servlet at tomcat startup
Date Mon, 05 Nov 2007 10:52:19 GMT


Johnny Kewl wrote:
>
> --------------------------------------------------------------------------- 
>
> HARBOR: http://coolharbor.100free.com/index.htm
> Now Tomcat is also a cool pojo application server
> --------------------------------------------------------------------------- 
>
> ----- Original Message ----- From: "Johnny Kewl" <john@kewlstuff.co.za>
> To: "Tomcat Users List" <users@tomcat.apache.org>
> Sent: Monday, November 05, 2007 12:18 PM
> Subject: Re: running! a servlet at tomcat startup
>
>
>>
>> --------------------------------------------------------------------------- 
>>
>> HARBOR: http://coolharbor.100free.com/index.htm
>> Now Tomcat is also a cool pojo application server
>> --------------------------------------------------------------------------- 
>>
>> ----- Original Message ----- From: "loredana loredana" 
>> <loredana888888@yahoo.com>
>> To: "Tomcat Users List" <users@tomcat.apache.org>
>> Sent: Monday, November 05, 2007 11:48 AM
>> Subject: Re: running! a servlet at tomcat startup
>>
>>
>> thanks for the response johnny. That's probably the only way it can 
>> be done.. Unfortunatelly for me, I need variables like 
>> request.getContextPath() and from init() method i can't "retrieve" 
>> those values. 10x a lot anyway.
>> ===================================
>> Ah, I see now...
>> Yes parsing context.xml is too much hassle..
>>
>> Heres an idea...
>> When someone drops a WAR in, the context always takes on the webapp 
>> name.
>> ie for most apps... webapp name = context
>> So try this...
>>        ServletContext context = getServletContext();
>>        String sWebBase = context.getRealPath("/");
>
> MEL just told me that    context.getServletContextName()
>
> is easier ;)

Be careful! AFAIK, getServletContextName() returns "display-name" value, 
not real context name - please check API!



>>
>> Than last folder is the context name...
>> Some String parsing and you got it ;)
>>
>> Good luck
>>
>> ===================================
>>
>>
>>
>> ----- Original Message ----
>> From: Johnny Kewl <john@kewlstuff.co.za>
>> To: Tomcat Users List <users@tomcat.apache.org>
>> Sent: Monday, November 5, 2007 10:58:54 AM
>> Subject: Re: running! a servlet at tomcat startup
>>
>>
>>
>> --------------------------------------------------------------------------- 
>>
>> HARBOR: http://coolharbor.100free.com/index.htm
>> Now Tomcat is also a cool pojo application server
>> --------------------------------------------------------------------------- 
>>
>> ----- Original Message ----- From: "loredana loredana" 
>> <loredana888888@yahoo.com>
>> To: <users@tomcat.apache.org>
>> Sent: Monday, November 05, 2007 10:32 AM
>> Subject: running! a servlet at tomcat startup
>>
>>
>> This issue is a classic one already I think. I've googled it and
>> haven't
>> found anything that could help solving this problem. I'm probably not
>> the
>> one to think about this but...if you would add the
>> <load-on-startup>1</load-on-startup> to a servlet, and from the init()
>> method you would somehow try to call the doGet() method, wouldn't that
>> do
>> it? wouldn't that run the servlet at startup?  did anybody try this
>> already?
>> I am trying to do this but I'm having some problem creating
>> HttpServletRequest and Response objects so I can call doGet(). So if
>> anyone
>> did this already, pls let me know how this issue can be fixed! 10x a
>> lot!
>> =======================
>> Hi  loredana,
>> Not sure if you asking or answering ;)
>>
>> Yes, <load-on-startup> and then do stuff in the INIT method.
>> No, why try call doGet().... just init the functions that need initing,
>> like
>> the dBPool, or image processing.
>> The doGet implies you want to return info to a browser.... there isnt
>> one?
>> The Init method runs just once.... thats the idea.
>> <load-on-startup> just lets you get the INIT out of the way, otherwise
>> it
>> will happen on the first browser request, and if it takes a long time
>> the
>> browser will seem very slow to the user... but that only happens once
>> anyway.
>> ????????
>> ========================
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Tired of spam?  Yahoo! Mail has the best spam protection around
>> http://mail.yahoo.com
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message