• Post Reply Bookmark Topic Watch Topic
  • New Topic

Dispatch request to non defined servlets  RSS feed

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've servlets that are in the WEB-INF/lib directory, however, I want to be able to dispatch requests to them without defining them in web.xml file.
Is this possible? The reason I want to do this is because I am putting in new servlets in application server's class loader, and do not want to go through every webapps to add the servlets.
How about dispatching requests to servlets that are defined in web.xml, but not mapped to a URL.
Thanks in advance.
 
Jignesh Malavia
Author
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chu Tan:
...The reason I want to do this is because I am putting in new servlets in application server's class loader, and do not want to go through every webapps to add the servlets.

Depends on the servlet container or the application server that you are using. In Tomcat, there is a web.xml file in the TOMCAT_HOME/conf directory. This web.xml defines the default elements for all the webapps. For example, there are five pre-defined servlets named default, invoker, jsp, ssi, and cgi. You can add your new servlets and their url-mappings and they too will be available to all the webapps. And since url-mappings are relative to the webapp context, the same mapping will work for all the webapps; you don't have to map them individually for each webapp unless you want to override or extend the common one.
Is that what you were looking for?
Hope that helps,
-j
[ February 25, 2003: Message edited by: Jignesh Malavia ]
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, that should solve my problem..
I was trying to find out documentations of directly accessing servlets by their classname.
eg.
http://server/ctx/servlets/com/test/MyServlet
Can't seem to work on Tomcat 4.1.12 . Is it still supported? Does it allow loading servlets from webapp, common and shared scopes? Are there security issues regarding this?
 
Ivan Tamayo
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, the way to call servlets by their name is:
http://server/ctx/servlet/com.company.TestServlet
Since Tomcat 4.1.12, this pattern is no longer valid, it has been *deprecated* by security reasons.
However, you can activate it by "decommenting" the following code fragment in the
%TOMCAT_HOME%conf/web.xml,

In the file, this code is commented.
You also can include this code in the web application web.xml file only.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!