Jim,

You said it was LogonAction, so there is a request object in the execute method.

Jack


On Sun, 09 Jan 2005 15:43:25 +0000, Jim Douglas <[EMAIL PROTECTED]> wrote:
> 
> This line gives me a "cannot find symbol variable request"
> String userID = request.getParameter("userID");
> 
> This line gives me a "cannot find symbol variable request"
> String userID = request.getSession().getAttribute("userID");
> 
> 
> This line gives me a "cannot find symbol variable request"
> HttpSession session = request.getSession();
> String userID = session.getAttribute("userID");
> 
> This is not a servlet so request is not available.  There has to be a way
> for non-servlet classes in a web app to access the session object?  Correct?
> 
> Jim
> 
> >From: Dakota Jack <[EMAIL PROTECTED]>
> >Reply-To: Dakota Jack <[EMAIL PROTECTED]>
> >To: Struts Users Mailing List <user@struts.apache.org>
> >Subject: Re: Attributes, Parameter or Class
> >Date: Sat, 8 Jan 2005 21:18:53 -0800
> >
> >String userID = request.getSession().getAttribute("userID");
> >
> >or
> >
> >HttpSession session = request.getSession();
> >String userID = session.getAttribute("userID");
> >
> >However, really, as you have been told twice, what you want is:
> >
> >String userID = request.getParameter("userID");
> >
> >RIght?
> >
> >Jack
> >
> >
> >On Sun, 09 Jan 2005 02:44:42 +0000, Jim Douglas <[EMAIL PROTECTED]> wrote:
> > >   I can connect and authenticate via a database no problem. My problem
> >is I
> > > can't compile because of this line,
> > >
> > > String userID = session.getAttribute("userID"); - gives an error "cannot
> > > find symbol variable session"
> > >
> > > So I changed it to this,
> > >
> > > String userID = HttpSession.getAttribute("userID");
> > >
> > > ...and I get an error message that says, "non-static methods
> > > getAttribute(java.lang.String) cannot be referenced from a static
> >context"
> > >
> > > The answer may be my syntax on that line, I'm not sure.
> > >
> > > (This is the code, it's not a servlet)
> > >
> > > public class SQL92FormDetailDAO implements FormDetailDAO {
> > >
> > >          private Connection connection;
> > >          public SQL92FormDetailDAO(Connection connection) {
> > >                  this.connection = connection;
> > >          }
> > >
> > >          public List listFormDetail() {
> > >                  List items = new ArrayList();
> > >                  Statement statement =null;
> > >                  try {
> > >                          statement = connection.createStatement();
> > >                          String userID = session.getAttribute("userID");
> > >                          String query = "select name, formdetail  from "
> > >                              + "forms where userID = " + userID;
> > >
> > >
> > > Thank for the great responses!
> > > -Jim
> > >
> > > >From: Larry Meadors <[EMAIL PROTECTED]>
> > > >Reply-To: Larry Meadors <[EMAIL PROTECTED]>
> > > >To: Struts Users Mailing List <user@struts.apache.org>
> > > >Subject: Re: Attributes, Parameter or Class
> > > >Date: Sat, 8 Jan 2005 17:06:34 -0700
> > > >
> > > >Sorry Jim, I have to agree with the other posters...this is a really
> > > >unclear question.
> > > >
> > > >I think what you are asking is this: When a user logs in, i want to
> > > >put the user id and password somewhere that i can always find it
> > > >easily.
> > > >
> > > >If so, put it in session scope. It will be there until the session
> > > >expires, and you can get to it from a JSP or servlet.
> > > >
> > > >If you need it available from everything in the web app, you could use
> > > >something like a filter in conjunction with ThreadLocal to do
> > > >that...but I do not think that is such a great idea. IMO, keeping it
> > > >in session, and passing it to your model is a cleaner and more
> > > >maintainable design.
> > > >
> > > >Larry
> > > >
> > > >
> > > >On Sat, 08 Jan 2005 19:25:15 +0000, Jim Douglas <[EMAIL PROTECTED]>
> >wrote:
> > > > > I have an LogonForm, LogonAction and when a user successfully logs
> >on, I
> > > >set
> > > > > Attributes for "userID" and "userName".
> > > > >
> > > > > How would be the best way to make this information available to the
> >Web
> > > >App
> > > > > regardless of whether I need the data from within a JSP, servlet or
> > > >class
> > > > > file(for example, building a dynamic query)
> > > > >
> > > > > This is what I was trying to do and raised this issue(I can't get it
> >to
> > > > > work)
> > > > >
> > > > > public class SQL92FormDetailDAO implements FormDetailDAO {
> > > > >
> > > > >         private Connection connection;
> > > > >         public SQL92FormDetailDAO(Connection connection) {
> > > > >                 this.connection = connection;
> > > > >         }
> > > > >
> > > > >         public List listFormDetail() {
> > > > >                 List items = new ArrayList();
> > > > >                 Statement statement =null;
> > > > >                 try {
> > > > >                         statement = connection.createStatement();
> > > > >                         String userID =
> >session.getAttribute("userID");
> > > > >                         String query = "select name, formdetail
> >from "
> > > > >                             + "forms where userID = " + userID;
> > > > >
> > > > > Thanks,
> > > > > Jim
> > > > >
> > > > >
> >---------------------------------------------------------------------
> > > > > 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]
> > >
> > >
> >
> >
> >--
> >------------------------------
> >
> >"You can lead a horse to water but you cannot make it float on its back."
> >
> >~Dakota Jack~
> >
> >"You can't wake a person who is pretending to be asleep."
> >
> >~Native Proverb~
> >
> >"Each man is good in His sight. It is not necessary for eagles to be
> >crows."
> >
> >~Hunkesni (Sitting Bull), Hunkpapa Sioux~
> >
> >-----------------------------------------------
> >
> >"This message may contain confidential and/or privileged information.
> >If you are not the addressee or authorized to receive this for the
> >addressee, you must not use, copy, disclose, or take any action based
> >on this message or any information herein. If you have received this
> >message in error, please advise the sender immediately by reply e-mail
> >and delete this message. Thank you for your cooperation."
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> 


-- 
------------------------------

"You can lead a horse to water but you cannot make it float on its back."

~Dakota Jack~

"You can't wake a person who is pretending to be asleep."

~Native Proverb~

"Each man is good in His sight. It is not necessary for eagles to be crows."

~Hunkesni (Sitting Bull), Hunkpapa Sioux~

-----------------------------------------------

"This message may contain confidential and/or privileged information.
If you are not the addressee or authorized to receive this for the
addressee, you must not use, copy, disclose, or take any action based
on this message or any information herein. If you have received this
message in error, please advise the sender immediately by reply e-mail
and delete this message. Thank you for your cooperation."

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

Reply via email to