Java/JSP/Form TextArea
Submitting Text Areas
//File: index.html
<HTML>
<HEAD>
<TITLE>Submitting Text Areas</TITLE>
</HEAD>
<BODY>
<H1>Submitting Text Areas</H1>
<FORM ACTION="formAction.jsp" METHOD="POST">
Please enter your text:
<BR>
<TEXTAREA NAME="textarea1" ROWS="5"></TEXTAREA>
<BR>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</BODY>
<HTML>
//File: formAction.jsp
<HTML>
<HEAD>
<TITLE>Reading Text Areas</TITLE>
</HEAD>
<BODY>
<H1>Reading Text Areas</H1>
You typed:
<BR>
<%
StringBuffer text = new StringBuffer(request.getParameter("textarea1"));
int loc = (new String(text)).indexOf("\n");
while(loc > 0){
text.replace(loc, loc+1, "<BR>");
loc = (new String(text)).indexOf("\n");
}
out.println(text);
%>
</BODY>
</HTML>