• Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet throws stackOverflowException  RSS feed

 
senthil balan
Greenhorn
Posts: 2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I am new to servlet i am having a sample application which gets the name and email id and marks from the html page adn display the result in a jsp page.

when i use the cofiguration in url-pattern like <url-pattern>sample.do</url-pattern> and action attribute in HTML form like action = "sample.do" its work fine
please find the code below

web.xml
------------
<servlet>
<servlet-name>ExampleApp</servlet-name>
<servlet-class>example.newp.web.Example</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ExampleApp</servlet-name>
<url-pattern>/sample.do</url-pattern>
</servlet-mapping>

HTML form
------------

<form name="ex" method="post" action="sample.do" >

but when i modify my code like below

<form name="ex" method="post" action="sample/do/act.do" >

Web.xml
---------
<servlet-mapping>
<servlet-name>ExampleApp</servlet-name>
<url-pattern>/sample/do/*</url-pattern>
</servlet-mapping>

its not working and giving the below exception

javax.servlet.ServletException: Servlet execution threw an exception
example.newp.web.Example.doPost(Example.java:46)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

reet cause :stackOverFlowException

i have read in books that if we use wildcard in url pattern,it will accept whatever replaces the * but i dont know what mistake i have made can any one please help me to sort out this problem and suggest a good article regarding configuring web.xml file
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What makes you think that the error is in the web.xml when the stack trace shows:
 
senthil balan
Greenhorn
Posts: 2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear thanks for the immediate response, when i change the url-pattern as having the wild card like <url-pattern>/sample/do/*</url-pattern>,the stack trace throws error,but when i am using the url-pattern like <url-pattern>/sample.do</url-pattern> or <url-pattern>*.do</url-pattern> and action in HTML form like action = "sapmle.do" its works fine,i guses when i using the action in the HTML form like action = "Sample/do/act.do" with the url pattern <url-pattern>/sample/do/*</url-pattern> only its throwing error

In the servlet class Example.java the line RequestDispatcher rd=req.getRequestDispatcher("/result.jsp"); only throws the exception,but the same works fine when iam using url pattern matching same as the action attribute in HTML.,as i am new to this topic please help me to sort out this ,kindly bear me if i made any mistakes .
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps seeing the code might help? Please UseCodeTags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!