Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

facing problem deploying this servlet , can anyone help ??

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache Tomcat/4.0.3 - HTTP Status 404 - /ch03/servlet/Time2
--------------------------------------------------------------------------------
type Status report
message /ch03/servlet/Time2
description The requested resource (/ch03/servlet/Time2) is not available.
i am pasting servlet & web.xml , please help
servlet
******
package com.wrox.projsp.ch03.time.controller;
import java.util.Enumeration;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TimeServlet2 extends HttpServlet {
public void init() {
log("Init was called");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log("doGet was called");
response.setContentType("text/html");
PrintWriter out = response.getWriter();

out.println("<html>");
out.println("<head><title>");
out.println("Time Entry System");
out.println("</title></head>");

out.println("<body>");

out.println("<h2>Welcome to the Time Entry System</h2>");
out.println("<form action=Time2 method=POST>");
String event = request.getParameter("EVENT");
if (event==null) {
} else if (event.equals("ADMIN")) {
out.println("<h2>Administration Information</h3>");

out.println("<h3>Webapp & Servlet Engine Info</h3>");
ServletContext context = getServletContext();
out.println("<ul>");
out.println("<li> Server Info :" + context.getServerInfo());
out.println("<li> Major Version:" + context.getMajorVersion());
out.println("<li> Minor Version:" + context.getMinorVersion());
out.println("<li> Webapp Init Parameter:");
Enumeration webappParams = context.getInitParameterNames();
out.println("<ul>");
while (webappParams.hasMoreElements()) {
String paramName = (String) webappParams.nextElement();
String paramValue = context.getInitParameter(paramName);
out.println("<li>" + paramName + "=" + paramValue);
}
out.println("</ul>");
out.println("<h3>Servlet Info</h3>");
ServletConfig config = getServletConfig();
out.println("<li>Last Modified : " + getLastModified(request));
out.println("<li>Servlet Info : " + getServletInfo());
out.println("<li>Servlet Name : " + config.getServletName());
out.println("<h3>Servlet Init Parameters</h3>");
Enumeration servletInitParams = config.getInitParameterNames();
out.println("<ul>");
while (servletInitParams.hasMoreElements()) {
String paramName = (String) servletInitParams.nextElement();
String paramValue = config.getInitParameter(paramName);

out.println("<li>" + paramName + "=" + paramValue);
}

out.println("</ul>");
out.println("</ul>");

}
out.println("</form>");
out.println("</body>");
out.println("</html>");


}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log("doPost was called");
doGet(request, response);
}
}

web.xml
*******
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Applcation 2.3//EN"
"http://java.sun.com/j2ee/dtds/web-app_2_3.dtd">;

<web-app>
<context-param>
<param-name>thisIsMyThirdParam</param-name>
<param-value>3</param-value>
</context-param>
<context-param>
<param-name>thisIsMyFourthParam</param-name>
<param-value>4</param-value>
</context-param>

<servlet>
<servlet-name>
Time2
</servlet-name>
<servlet-class>
com.wrox.projsp.ch03.time.controller.TimeServlet2
</servlet-class>

<init-param>
<param-name>thisIsMyFirstParam</param-name>
<param-value>1</param-value>
</init-param>
<init-param>
<param-name>thisIsMySecondParam</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
</web-app>
[ June 19, 2002: Message edited by: prateek shah ]
[ June 19, 2002: Message edited by: prateek shah ]
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can u tell me how u r accessing the page.
If u access like /ch03/servlet/Time2,then I think u r using an application named(ch03).Inthat case u have to put the class file under (tomcat-root)/webapps/cho3/WEB-INF/classes/
U will create package structure under this.
web.xml seems correct.
Write me if u face prb,(correct me if I am wrong)
A.Umar
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I blind or I can not see any servlet mapping in your web.xml ?
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
U need a tag like following for yr servlet
<servlet-mapping>
<servlet-name>TrialServlet</servlet-name>
<url-pattern>/com.dcx.admin.TrialServlet</url-pattern>
</servlet-mapping>
in the mapping section of web.xml
 
I would challenge you to a battle of wits, but I see you are unarmed - shakespear. Unarmed tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic