Link to home
Start Free TrialLog in
Avatar of shilpi84
shilpi84

asked on

Help! tomcat 5.5 does'nt run my servlet.

hi
i made servlet program:
________________________________
//A.java
import javax.servlet.*;
import java.util.Enumeration;
import java.io.IOException;

public class A implements Servlet
{
 public void init(ServletConfig c) throws ServletException
 {
   System.out.println("test1");
   Enumeration parameters=c.getInitParameterNames();
   while(parameters.hasMoreElements())
   {
        System.out.println("test2");
        String p=(String)parameters.nextElement();
        System.out.println("parameter name :"+ p);
        System.out.println("parameter value :"+c.getInitParameter(p));
   }
 }

 public void destroy(){}
 public void service(ServletRequest s,ServletResponse r) throws ServletException,IOException{}
 public String getServletInfo()
 {
   return null;
 }
 public ServletConfig getServletConfig()
 {
    return null;
 }
}
----------------------------------------------------

compiled it and put it in   c:\tomcat\webapps\h\WEB-INF\classes\     folder
i made the following web.xml and its in the folder-      c:\tomcat\webapps\h\WEB-INF\
------------------------------------------------------
<web-app>
  <servlet>
    <servlet-name>A</servlet-name>
    <servlet-class>A</servlet-class>
    <init-param>
      <param-name>admin</param-name>
      <param-value>ad@max</param-value>
    </init-param>
    <init-param>
      <param-name>number</param-name>
      <param-value>233</param-value>
    </init-param>
  </servlet>
  <servlet-mapping>
    <servlet-name>A</servlet-name>
    <url-pattern>/A</url-pattern>
  </servlet-mapping>

</web-app>
--------------------------------------------------------

now when i enter - http://localhost:8080/h/A

a blank page shows up.
tomcat is running fine and i've run another servlet program before which ran properly.

please help...
Avatar of suprapto45
suprapto45
Flag of Singapore image

>>"public class A implements Servlet"
should that be HttpServlet?
SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shilpi84
shilpi84

ASKER

i'm not extending HttpServlet, i'm implenting Servlet interface. so thats why i used it
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i'll check
these are the logs:

localhost.2006-10-19_____________________________________

Oct 19, 2006 3:31:11 PM org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: [org.apache.webapp.balancer.RuleChain: [org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: Redirect URL: http://jakarta.apache.org]]
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
_____________________________________________________________


stdout_20061019_______________________________________________

test1
test2
parameter name :admin
parameter value :ad@max
test2
parameter name :number
parameter value :233
_____________________________________________________________

every other log is empty
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I need to leave now. If you have any questions, I hope that objects can (definitely, he is genius here ;) ) help you.

David
> a blank page shows up.

what exactly do u expect?
thanks suprapto45!
objects i now understood why there is no output i didnt know that the output goes to a log or console when one implents Servlet interface.
Glad I could help :).