开发者

how give from html textarea line String java in jsp

Is such html code page jsp?

<form action="">
<div align="center"><textarea name="" cols="50" rows="4">welcome to my program</textarea></div>
</form>

if write in this textarea line. How the line translate in object String in servlet?

I'm know such the way.

  <form action="perform_action.jsp" method="post">
      <input type="submit" value="OK">
  </form>

perform_action.jsp:

if ( <all_ок> ) { 
    Sample.task(); 
}

may way do on the one page jsp? sorry for b开发者_如何学编程ad english.


Let the form action point to the servlet URL as definied in <url-pattern> in web.xml and give the input elements a name.

<form action="servleturl" method="post">
    <textarea name="text"></textarea>
    <input type="submit">
</form>

The submitted content will be available in doPost() method of servlet as request parameter where you use the name of the input element as parameter name.

String text = request.getParameter("text");

See also:

  • Servlets tag info page - contains hello world example and useful tutorial links
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜