Hi, I have written a simple servlet and trying to
access an init param from the web.xml but the servlet
is giving me a runtime error, please help, I'm stuck
here, my runtime error says..
[code]
HTTP Status 404 - Servlet invoker is not available
--------------------------------------------------------------------------------
type Status report
message Servlet invoker is not available
description The requested resource (Servlet invoker is
not available) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/5.0.28
[/code]
my code and web.xml fiels look like this..
InitParamServlet.java
[code]
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class InitParamServlet extends HttpServlet {
private String name;
public void init() throws ServletException {
name = (String)
getServletContext().getAttribute("name");
if (name == null)
{
name = "no name initialized";
throw new UnavailableException("Couldn't get
database.");
}
}
public void doGet(HttpServletRequest req,
HttpServletResponse res) throws IOException,
ServletException {
PrintWriter out = res.getWriter();
res.setContentType("text/html");
out.println("<html>");
out.println("<head> <meta
http-equiv=\"Content-Language\" content=\"en-gb\">
<meta http-equiv=\"Content-Type\"
content=\"text/html; charset=windows-1252\">");
out.println("<title>Hello</title>");
out.println("</head>");
out.println("<body>");
out.println("<p align=\"center\"> </p>");
out.println("<p align=\"center\"> </p>");
out.println("<p align=\"center\"><b><font
size=\"6\">Hello, My Name is " + name + " This is a
sample webpage, ");
out.println("</body>");
out.println("</html>");
}
}
[/code]
web.xml is
[code]
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<!-- JSPC servlet mappings start -->
<servlet>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<servlet-class>org.apache.jsp.index_jsp</servlet-class>
</servlet>
<servlet>
<servlet-name>InitParamServlet</servlet-name>
<servlet-class>InitParamServlet</servlet-class>
<init-param>
<param-name>name</param-name>
<param-value>Clint Fivefield!</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>InitParamServlet</servlet-name>
<url-pattern>/InitParamServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>org.apache.jsp.index_jsp</servlet-name>
<url-pattern>/index.jsp</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end -->
</web-app>
[/code]
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]