You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nick Stuart <ba...@gmail.com> on 2005/09/01 18:48:01 UTC

TAP4 upload path?

Hi all, did some digging and all I can find are references that will
work 3.0 but not for 4. So, what is the best way to get the actually
full path in your webcontext to upload files to? In 3 you could do
something like:
String path = getRequestCycle().getRequestContext().getServlet().getServletContext().getRealPath("/");

But in 4 the getRequestContext() is deprecated and there is no more
getServlet in the context. My first question was how does one get
ahold of the requestContext, or what seems to have replaced it,
'WebRequest'. and once you have it can you do anything with it to get
the actual path?

Thanks!
-Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: TAP4 upload path?

Posted by Nick Stuart <ba...@gmail.com>.
I agree, I started with the basic jsp/servlets before there was
anything like struts/jsf and now tapestry and their like. Not afraid
of the golden oldies if it gets the job done quicker and with less
pain.  :)

-Nick

ps. Plus I already had my InitServlet for starting up my Cayenne
context, so this was a simple 3 line addition =)

On 9/1/05, Patrick Casey <pa...@adelphia.net> wrote:
> 
>         I'm fairly old school, so a lot of my solutions kind of tend to
> sidestep the platforms I use :). It's all a matter of using the right tool
> for the right job.
> 
>         --- Pat
> 
> > -----Original Message-----
> > From: Nick Stuart [mailto:baredok@gmail.com]
> > Sent: Thursday, September 01, 2005 10:23 AM
> > To: Tapestry users
> > Subject: Re: TAP4 upload path?
> >
> > That works. Not very 'tapestry' like, but it works.  :)
> >
> > Thanks!
> >
> > On 9/1/05, Patrick Casey <pa...@adelphia.net> wrote:
> > >
> > >         How about putting this line in your servlet:
> > > public void init(ServletConfig config) throws ServletException {
> > >                 super.init(config);
> > >                 String temp =
> > > config.getServletContext().getRealPath("work");
> > >                 fWorkDirectory = temp;
> > >                 if (fDebug) {
> > >                         Log.info("NOT starting scheduler because we're
> > in
> > > debug mode");
> > >                         return;
> > >                 }
> > >                 ScheduleReader run = new ScheduleReader();
> > >                 run.setDaemon(true);
> > >                 run.setName("Schedule Reader");
> > >                 run.start();
> > >
> > >         }
> > >
> > >         public static String getWorkDirectory() {
> > >                 return fWorkDirectory;
> > >         }
> > >
> > >         Then whenever you need the work directory just do a
> > > MyServlet.getWorkDirector() to access the static.
> > >
> > >         --- Pat
> > >
> > > > -----Original Message-----
> > > > From: Nick Stuart [mailto:baredok@gmail.com]
> > > > Sent: Thursday, September 01, 2005 9:48 AM
> > > > To: Tapestry users
> > > > Subject: TAP4 upload path?
> > > >
> > > > Hi all, did some digging and all I can find are references that will
> > > > work 3.0 but not for 4. So, what is the best way to get the actually
> > > > full path in your webcontext to upload files to? In 3 you could do
> > > > something like:
> > > > String path =
> > > >
> > getRequestCycle().getRequestContext().getServlet().getServletContext().get
> > > > RealPath("/");
> > > >
> > > > But in 4 the getRequestContext() is deprecated and there is no more
> > > > getServlet in the context. My first question was how does one get
> > > > ahold of the requestContext, or what seems to have replaced it,
> > > > 'WebRequest'. and once you have it can you do anything with it to get
> > > > the actual path?
> > > >
> > > > Thanks!
> > > > -Nick
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: TAP4 upload path?

Posted by Patrick Casey <pa...@adelphia.net>.
	I'm fairly old school, so a lot of my solutions kind of tend to
sidestep the platforms I use :). It's all a matter of using the right tool
for the right job.

	--- Pat

> -----Original Message-----
> From: Nick Stuart [mailto:baredok@gmail.com]
> Sent: Thursday, September 01, 2005 10:23 AM
> To: Tapestry users
> Subject: Re: TAP4 upload path?
> 
> That works. Not very 'tapestry' like, but it works.  :)
> 
> Thanks!
> 
> On 9/1/05, Patrick Casey <pa...@adelphia.net> wrote:
> >
> >         How about putting this line in your servlet:
> > public void init(ServletConfig config) throws ServletException {
> >                 super.init(config);
> >                 String temp =
> > config.getServletContext().getRealPath("work");
> >                 fWorkDirectory = temp;
> >                 if (fDebug) {
> >                         Log.info("NOT starting scheduler because we're
> in
> > debug mode");
> >                         return;
> >                 }
> >                 ScheduleReader run = new ScheduleReader();
> >                 run.setDaemon(true);
> >                 run.setName("Schedule Reader");
> >                 run.start();
> >
> >         }
> >
> >         public static String getWorkDirectory() {
> >                 return fWorkDirectory;
> >         }
> >
> >         Then whenever you need the work directory just do a
> > MyServlet.getWorkDirector() to access the static.
> >
> >         --- Pat
> >
> > > -----Original Message-----
> > > From: Nick Stuart [mailto:baredok@gmail.com]
> > > Sent: Thursday, September 01, 2005 9:48 AM
> > > To: Tapestry users
> > > Subject: TAP4 upload path?
> > >
> > > Hi all, did some digging and all I can find are references that will
> > > work 3.0 but not for 4. So, what is the best way to get the actually
> > > full path in your webcontext to upload files to? In 3 you could do
> > > something like:
> > > String path =
> > >
> getRequestCycle().getRequestContext().getServlet().getServletContext().get
> > > RealPath("/");
> > >
> > > But in 4 the getRequestContext() is deprecated and there is no more
> > > getServlet in the context. My first question was how does one get
> > > ahold of the requestContext, or what seems to have replaced it,
> > > 'WebRequest'. and once you have it can you do anything with it to get
> > > the actual path?
> > >
> > > Thanks!
> > > -Nick
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: TAP4 upload path?

Posted by Nick Stuart <ba...@gmail.com>.
That works. Not very 'tapestry' like, but it works.  :)

Thanks!

On 9/1/05, Patrick Casey <pa...@adelphia.net> wrote:
> 
>         How about putting this line in your servlet:
> public void init(ServletConfig config) throws ServletException {
>                 super.init(config);
>                 String temp =
> config.getServletContext().getRealPath("work");
>                 fWorkDirectory = temp;
>                 if (fDebug) {
>                         Log.info("NOT starting scheduler because we're in
> debug mode");
>                         return;
>                 }
>                 ScheduleReader run = new ScheduleReader();
>                 run.setDaemon(true);
>                 run.setName("Schedule Reader");
>                 run.start();
> 
>         }
> 
>         public static String getWorkDirectory() {
>                 return fWorkDirectory;
>         }
> 
>         Then whenever you need the work directory just do a
> MyServlet.getWorkDirector() to access the static.
> 
>         --- Pat
> 
> > -----Original Message-----
> > From: Nick Stuart [mailto:baredok@gmail.com]
> > Sent: Thursday, September 01, 2005 9:48 AM
> > To: Tapestry users
> > Subject: TAP4 upload path?
> >
> > Hi all, did some digging and all I can find are references that will
> > work 3.0 but not for 4. So, what is the best way to get the actually
> > full path in your webcontext to upload files to? In 3 you could do
> > something like:
> > String path =
> > getRequestCycle().getRequestContext().getServlet().getServletContext().get
> > RealPath("/");
> >
> > But in 4 the getRequestContext() is deprecated and there is no more
> > getServlet in the context. My first question was how does one get
> > ahold of the requestContext, or what seems to have replaced it,
> > 'WebRequest'. and once you have it can you do anything with it to get
> > the actual path?
> >
> > Thanks!
> > -Nick
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: TAP4 upload path?

Posted by Patrick Casey <pa...@adelphia.net>.
	How about putting this line in your servlet:
public void init(ServletConfig config) throws ServletException {
		super.init(config);
		String temp =
config.getServletContext().getRealPath("work");
		fWorkDirectory = temp;
		if (fDebug) {
			Log.info("NOT starting scheduler because we're in
debug mode");
			return;
		}
		ScheduleReader run = new ScheduleReader();
		run.setDaemon(true);
		run.setName("Schedule Reader");
		run.start();

	}

	public static String getWorkDirectory() {
		return fWorkDirectory;
	}

	Then whenever you need the work directory just do a
MyServlet.getWorkDirector() to access the static.

	--- Pat

> -----Original Message-----
> From: Nick Stuart [mailto:baredok@gmail.com]
> Sent: Thursday, September 01, 2005 9:48 AM
> To: Tapestry users
> Subject: TAP4 upload path?
> 
> Hi all, did some digging and all I can find are references that will
> work 3.0 but not for 4. So, what is the best way to get the actually
> full path in your webcontext to upload files to? In 3 you could do
> something like:
> String path =
> getRequestCycle().getRequestContext().getServlet().getServletContext().get
> RealPath("/");
> 
> But in 4 the getRequestContext() is deprecated and there is no more
> getServlet in the context. My first question was how does one get
> ahold of the requestContext, or what seems to have replaced it,
> 'WebRequest'. and once you have it can you do anything with it to get
> the actual path?
> 
> Thanks!
> -Nick
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org