• Post Reply Bookmark Topic Watch Topic
  • New Topic

servlet mapping in Tomcat 6.0 - stack overflow  RSS feed

 
Sreeram La
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Tomcat 6.0. I am trying out a few servlet mapping examples. When I try out the following

<servlet>
<servlet-name>serv2</servlet-name>
<servlet-class>com.example.web.Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>serv2</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>


And try to use the link

<a href="Servlet1.do">
Servlet1.do
</a>

I get a stack overflow error.

java.lang.StackOverflowError
java.util.HashMap.containsKey(HashMap.java:335)
org.apache.catalina.connector.Request.removeAttribute(Request.java:1336)
org.apache.catalina.connector.RequestFacade.removeAttribute(RequestFacade.java:514

com.example.web.Servlet2.doGet(Servlet2.java:35)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
com.example.web.Servlet2.doGet(Servlet2.java:35)


I see that the doGet method is called recursively. Can someone explain what exactly is happening.

Also, when I try to configure

<servlet>
<servlet-name>serv2</servlet-name>
<servlet-class>com.example.web.Servlet2</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>serv2</servlet-name>
<url-pattern>foo/*</url-pattern>
</servlet-mapping>


I am unable to start my application (Though my book mentions this as a valid servlet mapping. I am using Head First JSP and Servlets).
[ January 13, 2008: Message edited by: Sreeram La ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<url-pattern>foo/*</url-pattern>


That pattern is not valid.
With the exception of extension mappings (*.jpg), the patterns must start with a forward slash.

From SRV.11.2


In theWeb application deployment descriptor, the following syntax is used to define
mappings:
� A string beginning with a �/� character and ending with a �/*� suffix is used

for path mapping.

� A string beginning with a �*.� prefix is used as an extension mapping.

� A string containing only the �/� character indicates the "default" servlet of
the application. In this case the servlet path is the request URI minus the context
path and the path info is null.

� All other strings are used for exact matches only.
 
Sreeram La
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!