I'm looking to offer the user some way of changing how a single page looks based on some pre-defined jsps.

i.e. Two or more jsp's contain similar information, and would be backed by a single controller method. The controller would decide which view to return.

  1. Is there a common way of achieving this?

    At the moment I have some administration screens where I control a list of possible views. The user can then choose which one to see from a drop-down.

    My current issue is that I don't know how to confirm (at the admin screen) that the view is valid.

  2. Is there a way of asking spring for all possible views so I can filter them and resent a drop-down on the admin screen rather than a free text field? If not is there a way of asking spring if a single view is valid?

    All these views will reside under a common directory, so it would probably be possible to scan recursively from that point and build a list of possible views.

This goes beyond simply changing the css, since the page content might be different despite being backed by the same model.

1 Answer 1


I think this needs some File system scanning in the back end at sprig container and Ajax calls in the Admin Screen this both combined will give you a solution I suppose.

My solution would be, when the client hits the Admin screen and tries to change the view then send the Ajax call to the server, The server instantly scans the list of all Views in the directory, (This is a "File" based scanning as you have explained) and returns Names of the views removing the extensions and in User readable format. (The view names should me user readable).

Try this. Ramakanth

  • Thanks Ramakanth, it's something I have considered. The views are configured in an admin screen so for now we do this manually (i.e the user is required to know the view path and css filename). Then the non-admin user can be presented with a list of views only an admin has added. I think this is the path we're going to take at-least for the short term. Thanks again.
    – Karl Walsh
    Dec 16, 2011 at 16:27
  • Not to worry. If you get it working give me a ping. I will be glad.
    – TRR
    Dec 20, 2011 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.