I have a jsp page with a drop-down control mid-way down the page. When the user changes the selection of the drop-down the page submits to a servlet and forwards back to the same page with details about the user selection to be displayed. I'd like the page to automatically navigate back to the drop-down instead of the user having to scroll back to it on their own.
In the servlet after the code that retrieves the appropriate data, I have:
String forwardTo = "/WEB-INF/jsp/task-create.jsp#taskTypeSelection"
request.getRequestDispatcher(forwardTo).forward(request, response);
The link in the jsp I want the servlet to go to is placed above the drop-down control and looks like:
<a name="taskTypeSelection" id="taskTypeSelection"></a>
<select class="form-control" id="taskTypeID" name="taskTypeID">
<option value="">Select a task type.</option>
<option...
However, this doesn't work and I get a 404 error when the Dispatcher tries to forward. Is there a way to make this work while using my current setup with the RequestDispatcher? I figure this would be less of a problem if I used HttpServletResponse.sendRedirect, but I am using RequestDispatcher for added security and because I have put all my jsps in the WEB-INF folder and therefore are inaccessible for sendRedirect (at least that is my understanding. A lot of this is new to me).
Thanks!