Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

requests get stuck in S status  RSS feed

marcello marangio
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all
I am having a strange problem on my tomcat 5.5.
I developed a very simple combo box cascade: if i select one of the coutries shown in the first one I dynamically load from a DB the cities of that coutry.
I use jquery to populate the second combo in a div; mybatis for data binding and Mysql ad RDBMS.

After a random number of selections of countries (less than 10) tomcat gets stuck a doesn't respond; there is a thread stuck in "S" state, forever.

This is my jsp

<script type="text/javascript">
function toggle_view2(id) {

$.post("<%=request.getContextPath()%>/servlet/", { id_ente: id.value, op:"searcities" },

<form action="/" method="post" name="lostpasswordform">
<table align="center" width=600>

<select name="id_country" id="id_country" onchange="toggle_view2(this)">
SqlSession sqlSession= Utils.getSqlSessionFactory().openSession( false);
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
List <Country> coutries = coutrnyeMapper.selectByExample(new CountryExample());
for(Country country:countries){%>
<option value="<%=country.getId() %>"><%=country.getName() %></option>
<div id="cities" ></div>


and this is my java code:

else if("searchcities".equals(op)){

session = Utils.getSqlSessionFactory().openSession( false);
CityMapper sm = (CityMapper) session.getMapper(City.class);
CityExample se = new CityExample();
String id_country = request.getParameter("id_country");
List <City> cities = sm.selectByExample(se);
request.setAttribute("cities", cities);

and, of course:
RequestDispatcher rd = request.getRequestDispatcher("/citiesAjax.jsp");
rd.forward(request, response);

here is the "citiesAjax.jsp"

<%@page import="java.util.List, it.puglia.innova.idp.model.*"%>
<jsp:useBean id="cities" scope="request" class="java.util.ArrayList"/>
<select name="city">
for(Object c: cities){
City city = (City) sport;%>
<option value="<%=city.getId()%>"><%=city.getName() %>%></option>

Here is my connector configuration:

<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"

and my jdbc config:

<Context >
<Resource name="jdbc/idp" auth="Container" type="javax.sql.DataSource"
username="root" password="root" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/idp_registrazione" maxActive="8"
maxIdle="4" />

Please help
Tim Holloway
Posts: 18715
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Get the Java code out of the JSPs and into Java-only files. It's a lot easier to debug (and maintain) that way.

2. Use Code Tags to make it easier for people to read your sample code/JSPs/XML files.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!