How to create a text area and submit text inside text area in JSP :

Required Files:

  • a.jsp
  • b.jsp

a.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="green">
<h1>Welcome 2 java8s.com</h1>
<from action="b.jsp" method="post">
Please write some text about java8s.com:
<br>
<textarea name="textarea1" rows="5"></textarea>
<br>
<input type="submit" value="Submit">
</form>
</body>
</html>

b.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor="red">
<H1>you have written</H1>
<BR>
<%
StringBuffer text = new StringBuffer(request.getParameter("textarea1"));
int loc = (new String(text)).indexOf('\n');
while(loc > 0)
{
text.replace(loc, loc+1, "
");
loc = (new String(text)).indexOf('\n');
}
out.println(text);
%>
</body>
</html>

Output



Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 9439202111  |  9658317757  |  0674-2361252

Comment