I am wondering if it is considered bad practice to store HTML content in a database or if it is unsafe.
I am looking to implement several forms into my system that will have different fields and can change regularly. I am wondering if it would be bad practice to create each form's unique layout and store them in my database. The users won't be able to modify the forms, submit HTML to the forms, or create their own form without hacking our database. I would then take the data that the user submits and validate it for special characters before submitting the data to a database table created for each form. My plan is to loop through the request parameters pulling out the key value pairs and either send the validated list to a stored procedure or a prepared statement. The field names would have the same name, or similar name, as the column name in the database. To ensure I have the correct order, I would store the information in a MAP so that I don't need to hope the information doesn't move around somehow.
The HTML page will be stored in a clob in the database along with the SQL needed to submit the data from the client. I might just store the table name that the data needs to be submitted to and build the statement around it.
Example:
String tableName = "Form1"; //pulled from the database
String sqlLayout = "INSERT INTO ? ("+/*dynamically generated ? based on MAP keys*/+ ") VALUES ("+ /*dynamically generated ? based on MAP values*/ +")";
//Then proceed to fill in ? in the standard prepared statement way.
To load the clob into the client page, I will use jQuery's .load() on a div in the JSP.
I work with a JavaEE application that releases only once a year.