running! a servlet at tomcat startup 2007-11-05 - By Johnny Kewl
Back
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- HARBOR: http://coolharbor.100free.com/index.htm Now Tomcat is also a cool pojo application server -- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- -- -- -- Original Message -- -- From: "loredana loredana" <loredana888888@(protected)> To: "Tomcat Users List" <users@(protected)> 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("/");
Than last folder is the context name... Some String parsing and you got it ;)
Good luck
===================================
-- -- Original Message ---- From: Johnny Kewl <john@(protected)> To: Tomcat Users List <users@(protected)> 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@(protected)> To: <users@(protected)> 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@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To start a new topic, e-mail: users@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ __ 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@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ To start a new topic, e-mail: users@(protected) To unsubscribe, e-mail: users-unsubscribe@(protected) For additional commands, e-mail: users-help@(protected)
|
|