I'm trying to set up a servlet that can be accessed from a wild card mapping. Please see my code snippets below.
It displays correctly if I hit: http://localhost:8080/servletBase/doc?id=56
The jsp displays the properly coded error with: http://localhost:8080/servletBase/doc
Many, many doGet exceptions, to the point of stack overflow with :http://localhost:8080/servletBase/doc/
Same as above, but this is my desired url structure (where 'item' can be anything): http://localhost:8080/servletBase/doc/item?id=65
web.xml
<servlet>
<servlet-name>Servlet One</servlet-name>
<servlet-class>com.web.servlet.Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet One</servlet-name>
<url-pattern>/doc/*</url-pattern>
</servlet-mapping>
servlet code
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String id = request.getParameter("id");
request.setAttribute("queryResult", id);
RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request, response);
}
jsp code
<%
out.println("The id passed was: " + request.getAttribute("queryResult"));
%>
ERROR
javax.servlet.ServletException: Servlet execution threw an exception
com.web.servlet.Servlet.doGet(Servlet.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.web.servlet.Servlet.doGet(Servlet.java:24)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.web.servlet.Servlet.doGet(Servlet.java:24)
...
...
...
java.lang.StackOverflowError
org.apache.catalina.connector.Request.setAttribute(Request.java:1414)
org.apache.catalina.connector.RequestFacade.setAttribute(RequestFacade.java:503)
com.web.servlet.Servlet.doGet(Servlet.java:22)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.web.servlet.Servlet.doGet(Servlet.java:24)
...
...
...