Re: Forward request from a jsp to differents servlets
Wednesday, December 26, 2001 05:11 AM
have each option have the value of the name of the servlet that you want to be accessed when users select that option from the menu. forward all requests to a controller servlet which based on the name can get to the servlet using ServletContext.getNamedDispatcher() method. pass the name of the servlet to this method and forward the request to it. this means that you need to have servlet names as setup in the web.xml in the client code which is not particularly nice so you can setup init parameters or something like to provide the mapping between the values you specify in the options on the client side and the actual names of the servlets deployed in your container. this is if you want to decouple the client from the server a bit further. if you do not care about that, simply have values of the options be names of the servlets you want request forwarded to and you will be good to go. it is pretty simple solution.