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
  • 27,194
  • 17
  • 102
  • 148
newbie
  • 14,582
  • 31
  • 104
  • 146

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,082,665
  • 372
  • 3,610
  • 3,555