I have an app. that displays objects and tags related to these objects (not a very original app). One difference is that tags have "types". Most have the simple type=object, but others have type=file. Depending on the tag, they will have different renderings. For example clicking an object tag shows other objects that match, but on the file tag, you can get other files that match, or click a download link to download the file.
I can do two things:
From the JSP call a method (in the main application) that renders the data being provided (which includes the tag's text, its url etc) and returns a string of html. so if only an `object_id` and `object_name` are provided this method signature will result in the _object renderer_ being called, but if a `file_id`, `file_name` and `file_location` are provided the method signature will result in the _file renderer_ method being called. However these methods necessarily contain/know about the html to be rendered (mixing code/html) which is not ideal.
Or I could have some if statements within the jsp which determine what the data type is that is being returned and then display the appropriate HTML accordingly.
I prefer the first option, since at least more happens with the Java so I can unit test more stuff easily, but is there a way in which there is no mixing of code and html required (while still using vanilla servlets and not some new framework).