I am programming a website using Servlets and JSPs and I am currently having a problem that if I enter something into my database (MySQL 5.x) with a line break "\n" it will not show up when I run a query on that data through my servlet. For some context: I am entering the data into the database using my Servlet and JDBC/ODBC and using encodeURIcomponent when I pass it from my page to my servlet using jQuery/AJAX .post method, the line breaks show up in the DATABASE and that is just fine. The problem is, when I run a query on the information using my Servlet (get method from JSP) I get the ResultSet and then turn that ResultSet into a Result in my Servlet and then pass that Result to my JSP where I iterate over it, and the linebreaks are no longer showing up.
Here is my code where I get the ResultSet and Result and then pass it to the JSP:
If you need to see any more code please let me know.
Again my problem is, I am trying to enter data into the database with line breaks, those linebreaks are carried over by jQuery/AJAX to my servlet which uses JDBC/ODBC to enter the data into my MySQL 5.x database (where the line breaks DO SHOW UP) and then I run a query on that data using my servlet and the ResulSet is then turned into a Result which is passed to my JSP and iterated over and when it is outputted into the JSP, the linebreaks are NOT showing back up.
Whitespace, including newlines, are irrelevant in HTML. If you want the newline to actually display as a a newline, you'll need to use HTML mechanisms to cause the text to wrap. <'br> is often used for this.