call java class by using servlet

i written simple servlet with doGet(0. I need call java class when i run servlet

my requirement is when i start the server i will call servlet it will redirect to another page.

but before that servlet will run java class. which i have written externally.

i need to run java class by using servlet then it will redirect to another page.

could you give the proper solution

[401 byte] By [sukumarreddy1234a] at [2007-11-26 18:35:38]
# 1

You don't call classes - you call methods.

There's nothing special about servlets except the requirement that they implement HttpServlet. Servlets and other classes they interact with all get compiled into WEB-INF/classes on the server.

To forward a request to, say, "other.jsp" you do:

getServletContext().getRequestDispatcher("/other.jsp").forward(request,response);

malcolmmca at 2007-7-9 6:09:43 > top of Java-index,Java Essentials,Java Programming...
# 2
The proper solution is to not "call a class", if you mean you want to do what the command line would do via "java myClass".You should rewrite your class so that you can create an instance of it and call its methods. Read some basic Java tutorials if you don't know how to do that.
DrClapa at 2007-7-9 6:09:43 > top of Java-index,Java Essentials,Java Programming...