You are doing it correctly. Debug and make sure your method isn't doing anything that requires a ServletContainer
. For example, if your GreetingServiceImpl has init()
and destroy()
implementations, they won't get called since you are using it as a Java class instead of a HttpServlet
. Also make sure your method doesn't need a HttpSession
since you won't have one.
I also recommend you use an instance variable instead of calling new GreetingServiceImpl();
all the time:
private static GreetingServiceImpl instance = null;
public static GreetingServiceImpl getInstance() {
if (instance == null) {
instance = new GreetingServiceImpl();
}
return instance;
}
So from then on, from the server side, you'd call:
String mSelect=GreetingServiceImpl.getInstance().getModel(Manufacturer);