-3
<label for="recs">Search picture</label><br>
<input type="text" id="recs" name="recs" value="${reco}" style="width: 292px; "/>

This is what I am using for accepting a value into the text box. How do I print the submitted value into the web page?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bala
  • 539
  • 1
  • 5
  • 8
  • Search charater
    – Bala Sep 26 '12 at 16:45
  • okay. Hi. This question is very simple and should not be asked, but I will answer, for printing out you most of the times write `document.write ()` In order to get the value it can be done in many ways, in Javascript it can be done using DOM. But you need some kind of trigger for printing out value, google events in javascript or go to w3schools u will get it. – Dhruvenkumar Shah Sep 26 '12 at 16:46
  • Are you confident that you aren't confusing Java/JSP with JavaScript? – BalusC Sep 26 '12 at 16:47
  • thank you. learning stage. Ws told do not hesitate to ask questions – Bala Sep 26 '12 at 17:06

2 Answers2

0

After submitting the form, you mean? Just get it from the request parameter map ${param} using the parameter name as key (the input field name becomes the request parameter name).

${param.recs}

Beware of XSS attacks however. Use either JSTL <c:out> or fn:escapeXml() to HTML-escape it.

<c:out value="${param.recs}" />

Note that Java/JSP have nothing to do with JavaScript.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • <% out.println(request.getParameter("reco")); %> – Bala Sep 26 '12 at 17:03
  • No, that's [oldschool way](http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files). Just use `${param.reco}`. You were already using EL in your code, so why falling back to legacy *scriptlets*? Note that your initial question isn't using `` anywhere. My answer is just targeted on your initial question. – BalusC Sep 26 '12 at 17:04
-1

you can use the following: <%= reco %> this will print the value

sheidaei
  • 9,842
  • 20
  • 63
  • 86