I'm sure that I'm just missing something very small here. This is more of a method visibility issue than a servlet issue so that is why I'm posting here. I have a servlet class, and I have another class for with DB connecting and RS returning. I'll post the snippets and then describe the error...
My servlet code...
This is just a snippet, I have some 'if' logic below the request.setAttribute, but that doesn't do anything except build a string and blah blah.
Here is the code for the connection class...
That is the whole class with both methods. My error is in the servlet class. In the line that says 'Connection opnConn = opnAS400Conn(url, libraryName, userName, password);' I am getting an error that says...
'The method opnAS400Conn(String, String, String, String) is undefined for the type FormManager'
FormManager is the name of my servlet, opnAS400Conn is the method in my class ConnDB. They are both part of the same package and both classes know that.
Why can't my servlet see that method in the other class?
The problem seems to be in this line of your Servlet class:
Note 2 things about this statement: - It can throw an Exception - It is executed by the constructor
I'm not a servlet expert so I don't know whether or not its legal to declare a constructor that can throw an exception. You could probably create the connection in the init() method and try to catch the exception, rethrowing it as a ServletException if needed.
posted 12 years ago
Thanks for the reply Tim. That took care of that error. My next question is this...
Down in my doPost I have some 'if' statements. They build a string buffer and then call this...
I use the opnConn that I created in the init() method. But it says opnConn cannot be resolved. Do I need to return it out of my init() method in order for my other methods to see it?
posted 12 years ago
I didn't have the right scope. I had to declare
above my init() method. Then the other methods could see it once I initialized it. Everything seems to be going ok for now. I'll know in a couple hours if this is going to work.
Do not meddle in the affairs of dragons - for you are crunchy and good with ketchup. Crunchy tiny ad: