Hi, This may be a stupid question but I am attempting to output a TEXTAREA with the content generated by JSP code enumerating through a vector of data. I have 2 problems, <TEXTAREA> JSP CODE HERE JSP CODE HERE </TEXTAREA> 1) I am finding that spaces between the JSP code is being resolved into the textarea, I know this is valid but is there a way of stopping it as I have to put all the jsp code on one line with no spaces. Any later reformatting of this will reintroduce the problem. 2) What do I put after each line to cause a carriage return, I've seen "%0D%0A%" but cant get this to work TIA Graham
monica
Greenhorn
Joined: Oct 08, 2002
Posts: 2
posted
0
I have the same problem as descibed on item two. Has anyone seen a solution on this problem???
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
Probably the best way to handle output of something like a text area is using custom tags. If you build a custom tag which emits the start and end of the TEXTAREA element, and place one or more custom tags which generate the content, inside it you will have much finer control over whether spaces and end-of-line characters are included in the content of the text area. If you are not comfortable with custom tags, you could write a general "helper" class to generate the whole TEXTAREA, and call your line-by-line code from it. As for your other question What do I put after each line to cause a carriage return, I've seen "%0D%0A%" but cant get this to work This puzzles me. Can you describe what you want to do in a bit more detail? A sequence like "%0D" looks like a URL-encoded version of an ASCII carriage return character. You would use an encoding lkike this if you were building a URL with GET parameters which included end-of-line characters. In a JSP, you would probably either put the end-of-line character in directly (in a text context such as a textarea), or maybe put in an HTML line-break ( <P/> or <BR/> ) in an HTML context. Do either of these sound like what you are trying to achieve? Or have I missed the point ?
hi graham here is what i understand from ur description, u have jsp output which u want to put in textarea but u don't want the spaces that is obeyed by jsp (e.g. if u write two jsp stmts in two lines then there are two lines in output), right?? i guess that the data u have as a result is string formatted as u want to put it in textarea. so why don't u do something like this, <% StringBuffer sb = new StringBuffer(); for(i=0; i < vector.size(); i++) { sb.append((String)vector.elementAt(i)); } %> <textarea> <%=sb.toString%> </textarea>
HI Regarding your 2nd query I faced a similar problem when I tried to redirect the page to another jsp page with the content of the textarea appended to the querystring.Response.encodeRedirectURL() didnt work.So i used java.net.URLEncode.encode() & it worked perfectly for me.Maybe u could try the same.