Hi all... I have a text area which I use to place text into a database. I had hoped that I would be able to also place html code in in this text box, upload it to a database as type text, retrieve it using a java bean, use a <bean:write> tag to write it into the JSP page, and have the page display it as if it was html code embedded directly into the page. I think that part of the problem is that characters such as < are getting converted into <. The data is stored correctly in the MySQL database, so there must be a conversion when it is placed in the bean using the get or set method. The data is being stored as a String variable in the bean... could this be the problem? The type of data in the db table is specified as text. Any ideas on how to proceed would be great. I'm trying to store html as I would like users to be able to modify the information in an html table by editing the code. Thanks, Ols
Joined: Mar 04, 2003
Update: Have refined the issue to this... I enter the following in a textarea
and insert it into a database. Later, I then retrieve this, and display it in a page using the <bean:write property /> tag. This results in the above code being displayed, rather than an HTML table being created. However, if I look at the source code of the page, the below code is shown (have had to insert spaces to show problem, else it renders as the original charaters):
How do I make the code display the correct characters i.e. <,> etc such that the browser renders it as code rather than text? Thanks... [ December 29, 2003: Message edited by: Oliver Moore ]
Joined: Jan 07, 1999
The transformation is probably being performed in bean:write. What I suggest is that you provide a new method in your bean which just returns the string you wish to display, and call it using <%= whateverMyBeanIsCalled.whateverMyMethodIsCalled() %> With any luck this should avoid the transformation.