Thank you all for helpful replies. I went around using the getRealPath(...) method of ServletContext successfully. Originally when I tried this out, null was returned as a result of the above method execution. The problem was that I deployed my Struts application in an archived format MyApp.war on a JBoss server. I'm not an JBoss expert, but it seemed that my application was running from within the war archive and the getRealPath(...) method doesn't like that hence returns null. I just extracted my war file to MyApp.war directory and that sorted the problem out.
--Alen ----- Original Message ----- From: "Claire Suttle" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Tuesday, August 19, 2003 10:14 PM Subject: Re: [OT] get abs path to my web application root context If you want to get the absolute path from within a Form or Action class, use: ServletContext serv = servlet.getServletContext(); String realPath = serv.getRealPath(filepath); filepath is the relative path from the root i.e. /images/items/path or /images/items/path/filename.gif You have inplicit access to servlet, so using these two lines and importing javax.servlet.ServletContext should be all you need to do. Claire --- In [EMAIL PROTECTED], Emerson Cargnin <[EMAIL PROTECTED]> wrote: > Servlet method : > getServletContext().getRealPath("/") > request has getRealPath, but is depracated. > > Don't know how to get this inside an action (besides using the > depracated method).maybe getting it at init servlet method and saving it > under application context. Any other ideas... > > > Alen Ribic wrote: > > Hi All > > > > This may be a bit of a silly and of topic question but this is driving me up > > the wall. ;) > > I would like to save uploaded files to my application's > > %app_root%/images/items/ path. > > How do I get the absolute path to my web application's root directory? > > e.g. "c:/tomcat/webapps/myapp_root/" > > > > Thanks > > > > --Alen > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > Emerson Cargnin > Analista de Sistemas > Setor de Desenvolvimento de Sistemas - TRE-SC > tel : (048) - 251-3700 - Ramal 3181 > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]