• Post Reply Bookmark Topic Watch Topic
  • New Topic

Combining static and dynamic content  RSS feed

 
Michael Arnett
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am trying to develop a web app using jsps, servlets, and some static html. The task I would like to complete, as elegantly as possible, is to generate dynamic pages utilizing jsps and servlets, but also to include certain static html elements. These static elements, however, change for different users. For instance, user1 and user2 have the same look and feel, but user3 has a different one. Is there a way to have several static html tables of menu buttons, for instance, that are included in a dynamic document based on some session or user variable(s). I also want to keep the static html elements in html or jsp files ( ie I do not want a javabean or servlet method which pieces together strings to create these tables...)
Thanks in advance,
-MLA
PS If this makes no sense let me know and I'll try to be more explicit or at least less convoluted....
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about something like this:
Does that help at all?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks like the best approach. However, i'd try to use polymorphism rather than "switch" style if statements. You might define a "UserParts" hierarchy of objects with methods for each static resource type, then write different subclasses that returned different static resources for inclusion.
Alternatively, this could all be done in data through Hashmap lookups.
Kyle
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
See my homepage at http://members.aol.com/kgb1001001 for other WebSphere information.
 
Michael Arnett
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with simply doing 'includes' like that is that the mixture of static and dynamic is a bit too tight to do that...or at least I think it is. Here is an example of what I mean:
There are lets say 5 menu items: sign in, sign out, home, security, and maintenance. User1 should see sign in and sign out only. User2 should see all except security. User3 should see all. How can I dynamically include the proper buttons without having a servlet define the presentation? Ideally, I was thinking of having the same jsp page for each user and have a bean that would define the menu and the content, but I am not currently clear on how to "build" a menu member from multiple static sources inside a bean. I guess I am looking for some code that would allow for me to say something like:
myMenu = menuItem1.jsp + menuItem3.jsp;
and then in the main jsp's menu section, just do a 'get' on the menu item. Any ideas?
Thanks in advance,
-MLA
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!