I understand that ideally HTML string should always be in JSP and not returned from Java file..But in my app, my JSP receives HTML string from Java class..
My question is can I modify that string dynamically or by some code in JSP..
E.g. based on certain condition in JSP, can i convert a 3-column table structure into a 2-col structure..in other cases, it would continue as returned by the Java class..
Thank you.
You can certainly do it in Java. If your HTML string is in valid XML, you can use XML manipulation for that.
Another option might be to use Javascript, and change the HTML on the client. jQuery makes it very easy.
Ideally though, you’d have a better separation of concerns in your application. Your Java class that returns HTML should really only return the essential information contained in that HTML, and let its callers decide on the representation of that information.