❮ Previous Next ❯

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

Required Files:

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




❮ Previous Next ❯

Follow Us




  Tutorials

Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Bhubaneswar-751013
      Email: info@silantechnology.com
      Phone: 0674-2361252
address
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved