How to call a specific method in a servlet from another servlet

Hi peeps, this post is kinda linked to my other thread but more direct !!

I need to call a method from another servlet and retrieve info/objects from that method and manipulate them in the originating servlet .... how can I do it ?

Assume the originating servlet is called Control and the servlet/method I want to access is DAO/login.

I can create an object of the DAO class, say newDAO, and access the login method by newDAO.login(username, password). Then how do I get the returned info from the DAO ?

Can I use the RequestDispatcher to INCLUDE the call to the DAO class method "login" ?

Cheers

Kevin

[645 byte] By [MrVenjera] at [2007-11-26 16:20:42]
# 1
You can use getrequestdispatcher.include(..), if you need to get some data back, you can store them as a request attribute.
dmitryra at 2007-7-8 22:44:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi Venjer, Can u say me how to create functions in Servlets
pdnsrka at 2007-7-8 22:44:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

Thanks for the reply.

So if I have a method in my DAO class called login() and I want to call it from my control servlet, what would the syntax be ?

getrequestdispatcher.include(newDAO.login())

where newDAO is an instance of the class DAO, would that be correct ? I'd simply pass the request object as a parameter in the login method and to retrieve the results of login() the requestdispatcher.include method will return whatever I set as an attribute to the request object, do I have that right ?!!!!

Kevin

MrVenjera at 2007-7-8 22:44:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
Sorry for the mis-information. I was getting my servlets and classes mixed up !!I am not calling a method in another servlet, I am calling a method in a normal class. The class does not implement HttpServlet.sorry for the wrong info.Message was edited by:
MrVenjera at 2007-7-8 22:44:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
Thanks for your reply
pdnsrka at 2007-7-8 22:44:19 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...