Similar Problem i have::
My servlet_lifecycle.java file is:
//servlet programs demonstrating its life cycle
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class servlet_lifecycle extends HttpServlet{
int i;
public void init() throws ServletException
{
i=0; //initializing i value-- parameters
}
//incrementing i value in doGet
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
if(i==0)
{
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet's Life Cycle</title>");
out.println("</head>");
out.println("</body>");
out.println("</h1>i value initialized in init method</h1>" + "<h1>"+ i + "</h1>");
out.println("</body>");
out.println("</html>");
}
i=i+1;
if(i==10)
{
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet's Life Cycle</title>");
out.println("</head>");
out.println("</body>");
out.println("</h1>i value reaches 10, hence calling destroy method to reset it</h1>" + "<h1>"+ i + "</h1>");
out.println("</body>");
out.println("</html>");
destroy();
}
if(i<10)
{
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet's Life Cycle</title>");
out.println("</head>");
out.println("</body>");
out.println("</h1>i value incremented in doGet method</h1>" + "<h1>"+ i + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
public void destroy()
{
i=0;
}
}
web.xml file is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_4.xsd"
version="2.4">
<description>
Servlet and
JSP Examples.
</description>
<display-name>Servlet and JSP Examples</display-name>
<servlet>
<servlet-name>servlet_lifecycle</servlet-name>
<servlet-class>servlet_lifecycle</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>servlet_lifecycle</servlet-name>
<url-pattern>/servlet_lifecycle</url-pattern>
</servlet-mapping>
</web-app>
Please help me.. i am new to servlets... i am geting error HTTP 503
HTTP Status 503 - This application is not currently available
type Status report
message This application is not currently available
description The requested service (This application is not currently available) is not currently available.
Apache Tomcat/6.0.32