I was using a textarea for taking user text input, but in order to retain the text formatting decided to try out tinyMCE.
What I need to do:
- Save the input entered into the tinyMCE editor to the database by posting the content to a servlet.
- Retrieve the saved text from the server and display it in the tinyMCE for any editing.
Problem Description: This is how I sent the text retrieved from the server to the front end JSP:
request.setAttribute('inputText',txt);
RequestDispatcher view = request.getRequestDispatcher("/TextareaTest.jsp");
view.forward(request, response);
In the JSP page I use JSTL/EL only. So to access the value in the request object I use ${requestScope['inputText']} or ${inputText}
Example:
<script type="text/javascript">
var txt = "${requestScope['inputText']}";
tinyMCE.get('textarea1').setContent(txt);
</script>
But this does not work with tinyMCE. Somehow I am not able to access the request object like I was able to before integrating tinyMCE. If I remove tinyMCE, it works fine. But now its like a normal textarea.
need to figure out how to access the value set on the request object by the servlet inside the javascript function.
Thanks