I have an issue trying to use getServletContext() on the server-side. This is marked as an error (underlined in red) and the hover over error is "The method getServletContext() is undefined for the type MySQLConnection" and the quick fix is to create the mothod.
I am using some code that was generated by someone else for gwtJava. I am now trying to use this in a JEE project. Unfortunately I have not been able to get help from the person who originally created this code and I am not a programmer and am learning as I go.
If you do not specify a base object or class for a method call, the method call is expected to be a member of the class that the method call logic is located in - or at least a superclass of that class.
Java is not like C/C++ where you have stand-alone functions. Java is fully object-oriented and every method must belong to a class.
That's where your error comes from. I can deduce that your sample code is in a class you created named "MySQLConnection" because the compiler cannot find a getServletContext method defined in your class definition.
The getServletContext() JEE method is a member method of class javax.servlet.http.GenericServlet and its descendents and one or two other servlet-related classes such as javax.servlet.http.HttpSession. So if you want the ServletContext, you either need to obtain it from the Servlet that is (presumably) calling MySQLConnection methods or from the HttpSession object for your webapp.
When it comes to destroying a civilization, gas chambers cannot hold a candle to echo chambers.
posted 3 months ago
Hi Tim Moores,
Yes, thank you. By removing getServletContext() from the ScoutMain.generateE1 and all reference to it in the called program it now works. If I can ever catch the person who produced the GWT version I will ask them why it was in there.
Hi Tim Holloway,
I understand the first three paragraphs of your reply; however, struggling with the last. I obviously need some education in this area; which I will see to.
Whatever you say buddy! And I believe this tiny ad too:
global solutions you can do in your home or backyard