1

I can get the value of a textfield from html to java using the following code:

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

Is there a way where I can set an HTML text field using a Java code?

Brad Mace
  • 26,397
  • 17
  • 98
  • 144
newbie
  • 14,136
  • 30
  • 101
  • 141

1 Answers1

6

Just let JSP/EL print it in the value attribute of the field.

<input type="text" name="id" value="${param.id}" />

or, better, to avoid XSS attacks, use JSTL fn:escapeXml().

<input type="text" name="id" value="${fn:escapeXml(param.id)}" />

See also:

Community
  • 1
  • 1
BalusC
  • 1,040,783
  • 362
  • 3,548
  • 3,513