aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes facing problem deploying this servlet , can anyone help ?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "facing problem deploying this servlet , can anyone help ??" Watch "facing problem deploying this servlet , can anyone help ??" New topic
Author

facing problem deploying this servlet , can anyone help ??

prateek shah
Ranch Hand

Joined: Sep 10, 2001
Posts: 31
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 ]

SCJP2<br />...SCWCD<br />wannabe SCEA
umar hathab
Ranch Hand

Joined: Aug 20, 2001
Posts: 52
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


Sun Certified Java Programmer for Java 2.0 (93%) <p>----Winners always make the learning a habit
Rozenkreutz
Greenhorn

Joined: Jun 17, 2002
Posts: 7
Am I blind or I can not see any servlet mapping in your web.xml ?
simmi arora
Greenhorn

Joined: Jun 19, 2002
Posts: 3
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: facing problem deploying this servlet , can anyone help ??