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?

1 Answer 1

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:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.