2

Im trying to send data from JSP to Controller.

I have smth like that in my JSP:

..
<form action="add.html" method="get">
<input type="hidden" name="type" value="<c:out value='${type}'/>"/>
<input type="submit" value="Add">
</form>
.. 
<input type="text" name="type">

What should i write instead of attr value to pass data?

1 Answers1

3

If a field is hidden, you typically are passing it down because you need it after the form is submitted. It's like a final variable that shouldn't be changed.

So you either want:

<form action="add.html" method="get">
    <input type="hidden" name="myValueAttr" value="${myValueAttr}" />
    <input type="submit" value="Add">
</form>

Or:

<form action="add.html" method="get">
    <input type="text" name="myValueAttr" />
    <input type="submit" value="Add">
</form>

I'm guessing you want the latter. Here is a link to a full explanation: Passing an object from JSP page back to Servlet

Community
  • 1
  • 1
keaplogik
  • 2,369
  • 2
  • 25
  • 26