0

I have a page that handles error when there's one textbox with no content. Now for example I have 3 textboxes then I only put text on the two textbox. When I submit the page an error handler like "*" will appear right beside the empty textbox before the submit procedure. But the contents of the two textboxes were gone so I need to retyped what I've type before. How to prevent this?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
PeterJohn
  • 589
  • 3
  • 8
  • 15

1 Answers1

1

Just redisplay the submitted value from the request parameter map.

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

The JSTL fn:escapeXml() is not mandatory for display, but it will save you from XSS attack holes.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • an error occured The attribute prefix fn does not correspond to any imported tag library – PeterJohn Jan 30 '13 at 15:03
  • :) Click the "JSTL" link in my answer to learn how to install/import it. Or ask a new question if you really stucks (I'd be surprised though). This is off topic to the current question. – BalusC Jan 30 '13 at 15:05
  • I solved already by placing `<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>` But how about if Im using a populated dropdown list? with this code `` – PeterJohn Jan 30 '13 at 15:09
  • how to implement this with dropdown list?It works fine with my textbox already – PeterJohn Jan 30 '13 at 15:13
  • Just let JSP print the `selected` attribute of the HTML ` – BalusC Jan 30 '13 at 16:43