Can't get the value of form in .jsp?

I can't get the value of the form - I still get 'null'. What am I doing wrong??

<br><br>
<form  method = "POST">
        <label>From:</label>
        <input type="date" name="inputFrom"
           value="2020-01-01"
           min="2000-01-01" max="2022-12-31">
</form>


<% out.println(request.getParameter("inputFrom")); %> 

Upvotes: 0

Views: 324

Answers (1)

Alex de Moraes
Alex de Moraes

Reputation: 101

The method POST only specifies what HTTP should be used to submit the form. It does not fire a submission. You may use a submit button to do it. Here you can see an example of how to build a minimum form and provides a submit button. In your code:

<br><br>
<form  method = "POST">
        <label>From:</label>
        <input type="date" name="inputFrom"
           value="2020-01-01"
           min="2000-01-01" max="2022-12-31">
    <input type="submit" value="Submit">
</form>
<% out.println(request.getParameter("inputFrom")); %> 

Upvotes: 1

Related Questions