<a>
cannot be used as you think you can. It is not one of the HTML elements which is dependent on a <form>
for a submit like <input>
, <textarea>
, <select>
etc.
You can read more about using <a>
here and about how to pass request-parameters in a URL here. Also somethings about HTML form and its elements.
so if your code is something like this:
<form action="/AddDescriptionForEvent.jsp" name="myForm">
<td>
<input type="text" name="someText" value="some Value" />
</td>
<td>
<span>
<a href="AddDescriptionForEvent.jsp?" name="count"><%=(cnt)%></a>
<span>
</td>
<input type="submit" value="Press me to Submit" />
</form>
Then on-clicking of the submit
button you would only be sending the value of the input someText
and not of count
.
To send the value of count
with other values make the following form:
<form action="/AddDescriptionForEvent.jsp" name="myForm">
<td>
<input type="text" name="someText" value="some Value" />
</td>
<td>
<span>
<!-- changed the <a> tag to <input> -->
<input type="text" name="count" value="<%=(cnt)%>" />
<span>
</td>
<input type="submit" value="Press me to Submit" />
</form>
or you can just use the following without the <form>
:
<td>
<span>
<a href="AddDescriptionForEvent.jsp?count=<%=cnt%>">Click this link to Add</a>
<span>
</td>
<!-- Notice the placement of the "cnt" variable of JSP -->
To also pass the other parameter on click of this <a>
link, modify the href
to href="AddDescriptionForEvent.jsp?count=<%=cnt%>&someText=some value"
These are the two way you can achieve your desired result. Your java code to fetch request-parameter is fine.