I'm not sure what to put in the subject but opinions sought please

Discussion in 'Java' started by Dundonald, Nov 12, 2007.

  1. Dundonald

    Dundonald Guest

    I'm not sure how to best ask this question so I hope I make myself
    clear :)

    I'm wondering what the best way to implement dynamic handling of
    customer defined functionality in a J2EE web app. For example ...

    A customer hitting URL http://www.somesite.com/someservlet?param=some_value

    is the obvious solution, the servlet can handle the logic on the
    paramater passed and act accordingly. What I'm wondering is, is it
    possible for a URL such as the following:


    that would automatically trigger a default / specified servlet and
    pass in "some_value" as a paramter to that servlet.

    Know what I mean?

    To put this in to context I will write code to allow the customer to
    configure certain functionality of the site and give that
    functionality a unique name. But rather than have that functionality
    requested by explicity calling a servlet and passing a paramater I
    would like it easier for the customer to remember by calling the site
    domain followed by the unique name of their functionality.
    Dundonald, Nov 12, 2007
    1. Advertisements

  2. Dundonald

    Juha Laiho Guest

    I wouldn't do quite that; that'd give a too good possibility for the
    customer to shoot themselves in the foot (f.ex. by using the same name
    with an existing servlet (or even static resource). This of course
    supposing that the same domain is used for anything else than this
    customizable functionality.
    Would it be possible to have the customer to remember one word in
    addition to their domain name? If so, you could create a servlet
    handler which would intercept all accesses to


    .... and then work its magic based on whatever is supplied as *.
    This would still be less things to remember than the HTTP query
    calling syntax. HP is one company using this; f.ex. you can try
    hp.com/go/java (which, by the way, does not redirect to Sun.. :)
    among others. These make great short links to be used f.ex. on
    brochures and training material.
    Juha Laiho, Nov 12, 2007
    1. Advertisements

  3. Dundonald

    Dundonald Guest

    Yes it's a good point but I've thought about that one :) I'll
    maintain a database record of reserved words that can't be used and
    when the customer defines their name it too (the name) will be stored
    in a database table so that any subsequent new names added will be
    checked against this table hence ensuring uniqueness.
    Thanks that's not a bad suggestion. The question I have then is how
    is the servlet handler created for a specific servlet to pick up
    anything from "go" for example and then does the servlet pick up *?
    To pick up * would the servlet still use request.getParamater()
    method? If so what paramater name would it use to pick up the content
    of *?

    Dundonald, Nov 12, 2007
  4. Dundonald

    derek Guest

    Look up information on the web.xml file.
    You can put something like this in there.


    The ServletABC then could look at the actual request and see where to send it based on the request.
    If you do a search for "servlet-mapping" you should get tons of examples.
    derek, Nov 12, 2007
  5. I agree with Derek.

    You could also look into setting up default parameters, in
    your deployment descriptor, and read them via obtaining either
    a "ServletConfig" or "ServletContext".


    <description>A town with crazy traffic</description>
    Chris ( Val ), Nov 13, 2007
  6. Dundonald

    Dundonald Guest

    Thanks I'll take a look.
    Dundonald, Nov 13, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.