Reading form data in the controller servlet



I am trying to read an input text box entry (simplest JSP) in my servlet code with httpservletrequest's getParameter method. I am using doHandle method of the BaseController class.

 JSP file -

<%@ include file="/include.jsp" %>
<c:url var="actionUrl" value="/pinnedbuildreport.html"/>
<form action="${actionUrl}" class="clearfix">
    Year: <input type="text" id="year" name="year"/>
    <input type="submit" name="submitButton" value="Run report" />


I tried without the 'id' attribute as well.


Reading the text entry in the servlet code like this -

  protected ModelAndView doHandle(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response) {

    final String targetYear = request.getParameter("year");

    do some stuff with 'targetYear'

    return null;


 'targetYear' variable is coming up as null.


My case seems to be exactly like this post -


Thanks you.

Please sign in to leave a comment.