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.getInitParame terNames() ;
while(parameters.hasMoreEl ements())
{
System.out.println("test2" );
String p=(String)parameters.nextE lement();
System.out.println("parame ter name :"+ p);
System.out.println("parame ter value :"+c.getInitParameter(p));
}
}
public void destroy(){}
public void service(ServletRequest s,ServletResponse r) throws ServletException,IOExcepti on{}
public String getServletInfo()
{
return null;
}
public ServletConfig getServletConfig()
{
return null;
}
}
-------------------------- ---------- ---------- ------
compiled it and put it in c:\tomcat\webapps\h\WEB-IN F\classes\ folder
i made the following web.xml and its in the folder- c:\tomcat\webapps\h\WEB-IN F\
-------------------------- ---------- ---------- --------
<web-app>
<servlet>
<servlet-name>A</servlet-n ame>
<servlet-class>A</servlet- class>
<init-param>
<param-name>admin</param-n ame>
<param-value>ad@max</param -value>
</init-param>
<init-param>
<param-name>number</param- name>
<param-value>233</param-va lue>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>A</servlet-n ame>
<url-pattern>/A</url-patte rn>
</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...
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.getInitParame
while(parameters.hasMoreEl
{
System.out.println("test2"
String p=(String)parameters.nextE
System.out.println("parame
System.out.println("parame
}
}
public void destroy(){}
public void service(ServletRequest s,ServletResponse r) throws ServletException,IOExcepti
public String getServletInfo()
{
return null;
}
public ServletConfig getServletConfig()
{
return null;
}
}
--------------------------
compiled it and put it in c:\tomcat\webapps\h\WEB-IN
i made the following web.xml and its in the folder- c:\tomcat\webapps\h\WEB-IN
--------------------------
<web-app>
<servlet>
<servlet-name>A</servlet-n
<servlet-class>A</servlet-
<init-param>
<param-name>admin</param-n
<param-value>ad@max</param
</init-param>
<init-param>
<param-name>number</param-
<param-value>233</param-va
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>A</servlet-n
<url-pattern>/A</url-patte
</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...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i'm not extending HttpServlet, i'm implenting Servlet interface. so thats why i used it
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i'll check
ASKER
these are the logs:
localhost.2006-10-19______ __________ __________ __________ _
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A pplication Context log
INFO: org.apache.webapp.balancer .BalancerF ilter: init(): ruleChain: [org.apache.webapp.balance r.RuleChai n: [org.apache.webapp.balance r.rules.UR LStringMat chRule: Target string: News / Redirect URL: http://www.cnn.com], [org.apache.webapp.balance r.rules.Re questParam eterRule: Target param name: paramName / Target param value: paramValue / Redirect URL: http://www.yahoo.com], [org.apache.webapp.balance r.rules.Ac ceptEveryt hingRule: Redirect URL: http://jakarta.apache.org]]
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A pplication Context log
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A pplication Context log
INFO: SessionListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.A pplication Context log
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.A pplication Context 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
localhost.2006-10-19______
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A
INFO: org.apache.webapp.balancer
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:11 PM org.apache.catalina.core.A
INFO: SessionListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.A
INFO: ContextListener: contextInitialized()
Oct 19, 2006 3:31:12 PM org.apache.catalina.core.A
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I need to leave now. If you have any questions, I hope that objects can (definitely, he is genius here ;) ) help you.
David
David
> a blank page shows up.
what exactly do u expect?
what exactly do u expect?
ASKER
thanks suprapto45!
ASKER
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 :).
should that be HttpServlet?