wood burning stoves 2.0*
The moose likes Servlets and the fly likes Invoking Servlets from an XML File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Invoking Servlets from an XML File" Watch "Invoking Servlets from an XML File" New topic

Invoking Servlets from an XML File

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
I am creating a framework which contains servlet names in an xml file.( sound familiar? ) Basically, just extending the functionality of servlet registering. The only problem is I pass a child class of HttpRequestWrapper between my servlets and on the first access the InvokerServlet pass a different child class and I am getting a class cast exception. Thusly, I would like to create an initialization servlet which will create an instance of each servlet in the xml file so this error will not occur on the initial access. Any help will be greatly appreciated.

SCJP 1.4
Atul Prabhu
Ranch Hand

Joined: Dec 17, 2002
Posts: 60

What i understand is that u want to dynamically load a servlet refering a xml file.

I think you can use

Object obj = (Class.forName("package.servlet")).newInstance();

this obj is the servlet object . You can then call the respective methods by using java.lang.reflect package.

Kerry Wilson
Ranch Hand

Joined: Oct 29, 2003
Posts: 254
Will this create an instance of the class that tomcat will use? Or will it still have to use the invoker servlet to create it's on when a request to one is made?
I agree. Here's the link: http://aspose.com/file-tools
subject: Invoking Servlets from an XML File
Similar Threads
Servlet cannot access bean/Servlet Not found
one servlet question
writing back to a xml file
java.sql.SQLException: Closed Connection
Serializing arguments to remote methods