Reading form data in the controller servlet

Hi,

 

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" />
</form>

 

I tried without the 'id' attribute as well.

 

Reading the text entry in the servlet code like this -

   @Override
  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 -

https://teamcity-support.jetbrains.com/hc/en-us/community/posts/206695475-Receiving-input-from-text-field

 

Thanks you.

Please sign in to leave a comment.