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-startup1/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! __ 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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-startup1/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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. - Original Message From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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-startup1/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL 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@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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(/); Than last folder is the context name... Some String parsing and you got it ;) Good luck === - Original Message From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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-startup1/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL 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@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
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: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 thatcontext.getServletContextName() is easier ;) Than last folder is the context name... Some String parsing and you got it ;) Good luck === - Original Message From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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-startup1/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL 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@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
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: Grzegorz Borkowski [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, November 05, 2007 12:52 PM Subject: Re: running! a servlet at tomcat startup Johnny Kewl wrote: --- HARBOR: http://coolharbor.100free.com/index.htm Now Tomcat is also a cool pojo application server --- - Original Message - From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 thatcontext.getServletContextName() is easier ;) Be careful! AFAIK, getServletContextName() returns display-name value, not real context name - please check API! Thanks MEL is blushing ;) Yes and the way I suggested will give you an extra context/build/web in the dev environment... so parsing gets a little tricky... unless of course all you really looking for in the web base folder. OK, now I'm officially wondering... if one cant get at Request... is there a better way to find the name of the web-app/context? Than last folder is the context name... Some String parsing and you got it ;) Good luck === - Original Message From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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-startup1/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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
Re: running! a servlet at tomcat startup
See Servlet.getServletConfig() and ServletConfig.getServletContext(). Wade - Original Message From: Johnny Kewl [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, November 5, 2007 6:16:17 AM Subject: Re: running! a servlet at tomcat startup OK, now I'm officially wondering... if one cant get at Request... is there a better way to find the name of the web-app/context? - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: running! a servlet at tomcat startup
No access to request??? Which AppServer are you running??? M-- - Original Message - From: Johnny Kewl [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, November 05, 2007 6:16 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: Grzegorz Borkowski [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, November 05, 2007 12:52 PM Subject: Re: running! a servlet at tomcat startup Johnny Kewl wrote: - -- HARBOR: http://coolharbor.100free.com/index.htm Now Tomcat is also a cool pojo application server - -- - Original Message - From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 thatcontext.getServletContextName() is easier ;) Be careful! AFAIK, getServletContextName() returns display-name value, not real context name - please check API! Thanks MEL is blushing ;) Yes and the way I suggested will give you an extra context/build/web in the dev environment... so parsing gets a little tricky... unless of course all you really looking for in the web base folder. OK, now I'm officially wondering... if one cant get at Request... is there a better way to find the name of the web-app/context? Than last folder is the context name... Some String parsing and you got it ;) Good luck === - Original Message From: Johnny Kewl [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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-startup1/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
Re: running! a servlet at tomcat startup
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Loredana, loredana loredana wrote: This issue is a classic one already I think. Hardly anyone actually wants to do this. Why do /you/ want to do this? - -chris -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.7 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHLyay9CaO5/Lv0PARAjkrAJ930aIwbV5smrCpPkqkU19gyXErmgCghI3v s/d106jHCS+bF3IkMd2+Opc= =PScw -END PGP SIGNATURE- - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: running! a servlet at tomcat startup
From: loredana loredana [mailto:[EMAIL PROTECTED] Subject: Re: running! a servlet at tomcat startup In case ur wondering why I used a servlet to fill the cache is because I need some variables like request.getContenxtPath, getRealPath() etc. Wouldn't a ServletContextListener be more appropriate for this kind of activity? See section 10 of the servlet spec for details. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: running! a servlet at tomcat startup
Yes, and in the listener I would then utilize some kind of other web client to actually perform a first request. You can use something like HttpClient or one of the command line text browsers and Runtime.exec. It would probably be easier than trying to simulate with some other means, but I may be wrong..especially if you already know what you are doing will work without having to have the extra client connection, but it would seem a lot less code to just have a config file you fill in and a client which makes a simple http web request. Wade - Original Message From: Caldarale, Charles R [EMAIL PROTECTED] To: Tomcat Users List users@tomcat.apache.org Sent: Monday, November 5, 2007 10:39:47 AM Subject: RE: running! a servlet at tomcat startup From: loredana loredana [mailto:[EMAIL PROTECTED] Subject: Re: running! a servlet at tomcat startup In case ur wondering why I used a servlet to fill the cache is because I need some variables like request.getContenxtPath, getRealPath() etc. Wouldn't a ServletContextListener be more appropriate for this kind of activity? See section 10 of the servlet spec for details. - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]