• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mapping a URL to a java class

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey all,

I'm trying to configure our Tomcat6 instance to map a URL request to a specific class within a jar file, and I'm having no luck thus far.

I've tried a few failed approaches, but I'm convincing myself a starting point for this communication is via the Context:



I've been hunting down anything I can find in the Tomcat documentation via google, but I can't see a way to do this...

Is it even possible?

thanks and much appreciate any help!
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Map it as a servlet or filter in web.xml.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't just do this willy-nilly.

You need to set up a proper web application, and the Java class being mapped needs to be a servlet.
 
Erik Yuzwa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bauke Scholtz wrote:Map it as a servlet or filter in web.xml.



Thanks, that's a great idea. I thought I already went down this road, but maybe there's something I overlooked in the servlet/filter tag
docs?
 
Erik Yuzwa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:You can't just do this willy-nilly.

You need to set up a proper web application, and the Java class being mapped needs to be a servlet.



Thanks Bear,

Not sure if you're commenting on my original post, or the suggestion of the servlet / filter....

I'm supporting a vendor object that is currently being served by an ancient / no-longer-support application server. I'm just attempting to migrate it into Tomcat..
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Erik Yuzwa wrote:

Bauke Scholtz wrote:Map it as a servlet or filter in web.xml.



Thanks, that's a great idea. I thought I already went down this road, but maybe there's something I overlooked in the servlet/filter tag
docs?


Hard to say as you never told us something about the actual problem.
 
Erik Yuzwa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry about that @Bauke

I don't want to "overpost", just because I don't want to bog this thread down with unneccessary information. I'll try to hyper-condense it.

problem: I have a URL request that needs to eventually find it's way to a specific Java object hosted by Tomcat: eg. /admin ---> com.foo.a

solution path:

1. Do nothing and hope for magic URL parsing by Tomcat. Result: unsuccessfull

2. Create a Servlet-Mapping within the web.xml of the Tomcat server. Result: unsuccessfull

3. Create a Filter mapping within the web.xml of the Tomcat server. Result: unsuccessfull

4. Create a new Context within the Tomcat server. Result: unsuccessfull

5. *new attempt* I'm changing focus to looking at the uriworkermap.properties definitions. Perhaps there's a way of defining the mapping there..

thanks again for any suggestions!



 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like that you need to enable the Tomcat's InvokerServlet.

Documentation here: http://tomcat.apache.org/tomcat-6.0-doc/funcspecs/fs-invoker.html

This is appserver specific stuff though. It won't work nor behave same on another appservers, so your webapp would be tight coupled to the appserver which may not be a good idea at all.

By the way, I should say that the InvokerServlet is by default disabled since Tomcat 5.5 due to security reasons. Please think twice about your design and choices.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why not just create a custom servlet that knows how to invoke the desired method in the class?

What does this class of yours produce that needs to go back to the client?

If the client side software is a browser, the servlet can provide the needed formatting to make an intelligible page.

Right off hand it looks like you are creating complexity where none needs to be.

Bill
reply
    Bookmark Topic Watch Topic
  • New Topic