aspose file tools*
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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Invoking Servlets from an XML File" Watch "Invoking Servlets from an XML File" New topic
Author

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.


http://www.goodercode.com
SCJP 1.4
Atul Prabhu
Ranch Hand

Joined: Dec 17, 2002
Posts: 60
Hi,

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.

---
Atul
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