Have you given a thought on my Singleton solution?

-Dan
----- Original Message -----
From: "Jason Long" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Saturday, March 29, 2003 9:48 PM
Subject: RE: application.getRealPath("/") from ActionForm???


> It is not static.  I need it to load when ActionForm is loaded.  Is there
no
> way to load form values from an external source?
>
> Jason Long - CEO and Chief Software Engineer
> Supernova Software - supernovasoftware.com
> BS Physics, MS  Chemical Engineering
>
> -----Original Message-----
> From: Dan Tran [mailto:[EMAIL PROTECTED]
> Sent: Saturday, March 29, 2003 11:42 PM
> To: Struts Users Mailing List
> Subject: Re: application.getRealPath("/") from ActionForm???
>
>
> Is your XML file static? If it does, you cam place the xml file in your
> class path and use my other posted solution to have access to its
> InputStream.
>
> If you dont like to place it in classpath, you can create a Singleton
> wrapper around your XML  and load it up during application startup, via
> Struts plugin or a servlet.
>
> -Dan
>
> ----- Original Message -----
> From: "Jason Long" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Saturday, March 29, 2003 9:31 PM
> Subject: RE: application.getRealPath("/") from ActionForm???
>
>
> > This file is and xml file that contain that data that the form needs to
be
> > filled with.  It is in my WEB-INF/data folder.  The problem is that I
> cannot
> > find a way to tell my form where to load this data from.  I need need to
> > access to the ServletContext so I can get the real path of the web
> > application.  Some has to know how to do this easily.
> >
> > Jason Long - CEO and Chief Software Engineer
> > Supernova Software - supernovasoftware.com
> > BS Physics, MS  Chemical Engineering
> >
> > -----Original Message-----
> > From: Dan Tran [mailto:[EMAIL PROTECTED]
> > Sent: Saturday, March 29, 2003 10:29 PM
> > To: Struts Users Mailing List
> > Subject: Re: application.getRealPath("/") from ActionForm???
> >
> >
> > My guess about the null control serverlet, is because struts may not
init
> > the form's control servlet after the form constructor completes.
> >
> >  If you can take a look at my answer to "Setting external JNDI
> properties",
> > you can put your file in classpath and load it.
> >
> >
> > BTW, you might have a performance problem loading the file for every
> > constructor of your action object.  You might want to load your file at
> > startup and access it thru a singleton.
> >
> > Good luck.
> >
> > -Dan
> >
> > ----- Original Message -----
> > From: "Jason Long" <[EMAIL PROTECTED]>
> > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > Sent: Saturday, March 29, 2003 7:53 PM
> > Subject: RE: application.getRealPath("/") from ActionForm???
> >
> >
> > > ActionServlet as = this.getServlet();
> > >
> > > This is returning null.  What is the proper way to get a reference to
> the
> > > controller servlet from and Action from?
> > >
> > > Jason Long - CEO and Chief Software Engineer
> > > Supernova Software - supernovasoftware.com
> > > BS Physics, MS  Chemical Engineering
> > >
> > > -----Original Message-----
> > > From: Jason Long [mailto:[EMAIL PROTECTED]
> > > Sent: Saturday, March 29, 2003 9:49 PM
> > > To: Struts Users Mailing List
> > > Subject: RE: application.getRealPath("/") from ActionForm???
> > >
> > >
> > > Actually I am calling a funtion that loads values into the form in the
> > > object.  This load method needs to find a relative path.  I cannot
seem
> to
> > > get a reference to the controller servlet or any other way to get the
> path
> > > to my WEB-INF.
> > >
> > > public final class ManagerForm extends ActionForm {
> > >   public ManagerForm() throws Exception {
> > >     this.load();
> > >   }
> > > ...
> > > ....
> > > ...
> > > }
> > >
> > > -----Original Message-----
> > > From: Dan Tran [mailto:[EMAIL PROTECTED]
> > > Sent: Saturday, March 29, 2003 8:25 PM
> > > To: Struts Users Mailing List
> > > Subject: Re: application.getRealPath("/") from ActionForm???
> > >
> > >
> > > If you deploy your app as a WAR file, then it is the correct result
> since
> > > there is no real directory to return
> > >
> > > But you can use this code
> > >
> > > InputStream is =
> > > servlet.getServletContext().getResourceAsStream(pathName);
> > >
> > > where pathName is the context path to your file in the WAR archive.
(ie
> > > /WEB-INF/yourFileName.txt)
> > >
> > > Good luck.
> > >
> > > -Dan
> > > ----- Original Message -----
> > > From: "Jason Long" <[EMAIL PROTECTED]>
> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> > > Sent: Saturday, March 29, 2003 1:07 PM
> > > Subject: application.getRealPath("/") from ActionForm???
> > >
> > >
> > > > When deploying my Struts application I ran in to a small problem.
> > > > I had hard coded the path to an xml file used to load values into my
> > form.
> > > > I need to get a relative path.  I tried the following, but got a
null
> > > > pointer.
> > > >
> > > > ActionServlet as = this.getServlet();
> > > > ServletContext application =
> as.getServletConfig().getServletContext();
> > > > String basePath = application.getRealPath("/");
> > > >
> > > > Thanks for your time,
> > > > Jason Long - CEO and Chief Software Engineer
> > > > Supernova Software - supernovasoftware.com
> > > > BS Physics, MS  Chemical Engineering
> > > >
> > > >
> > > >
> > >
> ---------------------------------------------------------------------
> > > > 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]
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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]
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > 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]
> >
> >
>
> ---------------------------------------------------------------------
> 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]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to