• 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

Dynamically list servlets (and request urls)?

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have this large very complex system and it contains several dispatchers and a few servlets that are defined in the web.xml file. One dispatcher in particular is a set of services.

Of course good documentation is important in this case, but the thought crossed my mind that it would be nice if I could create a page that dynamically listed the services available.

So the question is in two parts really
1. Can I programatically get a list of servlets and their mappings from the web.xml?
2. Can I programatically get a list of services bound via spring using RequestMapping annotations?

I hope that was not too confusing.
 
Ranch Hand
Posts: 243
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,

Please check the following links which will help you create a documentation page for all the @RequestMapping annotations in the @Controller classes.

  • RequestMappingHandler
  • demo


  • When it comes to web.xml, I'm not too sure. You can parse like any other xml file and map the servlet and servlet-mapping elements I guess.

    Thanks
    Srikkanth
     
    Sam Seaweed
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    It seems to be exactly what I want, but when I try it, I get



    For various reasons I am currently restricted to Spring version 3.1.0 if that could be the problem
     
    Ranch Hand
    Posts: 672
    4
    Eclipse IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Show us your XML/Java files, it looks like there is no matching bean defined.
     
    Sam Seaweed
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    How is the bean definition supposed to look for the RequestMappingHandlerMapping? I cannot find anything on the subject.

    The dispatcher and controller both work fine as long as I do not try to autowire a RequestMappingHandlerMapping instance into it.


    My dispatcher config


     
    Prasad Krishnegowda
    Ranch Hand
    Posts: 672
    4
    Eclipse IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    can you create the RequestMappingHandlerMapping bean as below.

    and autowire it in your CustomDispatcherDocumentation.
     
    Sam Seaweed
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I added the bean definition to my dispatcher XML (right after the component-scan definition), however, even without wiring the bean, all of the controllers fail with the following



    If I remove this bean definition, the other controllers start working again.

    I cannot find anything in the logs about the dispatcher failing to initialize or any errors except that when I request a URL in the dispatcher that is mapped I get the above error.
     
    Sam Seaweed
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    *Smack forhead* I was of course missing the annotation driven tag from my dispatcher configuration



    So of course the autowiring could not work.

    Big thanks for the help.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic