I have HttpServlet class called, let's call is Test. I can output anything from this class using HttpServletResponse object into my html page. Now, I have another a plain java class, let's call it Home, and in this class I need to out put something into the html page. Unfortunately, it doe snot work even I have tried to inherit HttpServlet from Home class and use HttpServletResponse object to out put.
Is there a way to redirect the output from the Home class to Test class ?
Here's the method doGetof my Test class, it create an object of home and call the method connectToHom() for authentication.
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String tst = "username"
tst = new Home();
tst.connectToHome(tst);
}
Here's the method connectToHome() of the class Home:
public void connectToHome(String tst){
-> Try to login using tst,
connect = Connection.open(tst);
if(connect.getMessage()!=null){
System.out.println("-- Error: " + connect.getMessage());
return null;
}
}
The above code works but it prints out on the console instead on the html page.
Thanks in advance!