File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes ServletContextListner not compiling 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 "ServletContextListner not compiling " Watch "ServletContextListner not compiling " New topic
Author

ServletContextListner not compiling

amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
hi.. i am not able to compile the foollowing class..

package com;
import javax.servlet.*;
import java.util.*;
import com.phoneDir;

class MyContextListener implements javax.servlet.ServletContextListner
{
public void contextInitialized(ServletContextEvent event)
{
System.out.println("context intialized");
ServletContext sc= event.getServletContext();
String args=sc.getInitParameter("name");

phoneDir ph= new phoneDir();
List phones=ph.getPhone(args);
sc.setAttribute("sc_ph",phones);
}

public void contextDestroyed(ServletContextEvent event)
{
System.out.println("contextDestroyed");

}

}


getting following error..


C:\Tomcat5014\webapps\jsp_prac\WEB-INF\src>javac com/MyContextListner.java
com/MyContextListner.java:6: cannot resolve symbol
symbol : class ServletContextListner
location: package servlet
class MyContextListener implements javax.servlet.ServletContextListner
^
1 error


any idea ranchers ?


Thanks and Regards, Amit Taneja
Narasimharao SV
Greenhorn

Joined: Feb 12, 2005
Posts: 9
Hello
please check the listener you are implementing there is no javax.servlet.ServletContextListner look at the spelling mistake in Listner it is not Listner it is Listener.

here the listener

javax.servlet.ServletContextListener

it could be the mistake .try to correct the mistake and deploy.

Narasimharao SV
Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Amit,

damn , you do it here again . Narasimharao is right. You always type Listner instead of Listener.

Regards,
Darya


SCJP, SCJD, SCWCD, SCBCD
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
thanx...
Narasimharao Sandrapaty
darya


i don't know what happend to me


regards,
amit
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
but after correcting spelling error

i m getting error on tomcat-(like dos command screen)

Jul 28, 2005 3:29:49 AM org.apache.catalina.startup.HostConfig restartContext
INFO: restartContext(/jsp_prac)
Jul 28, 2005 3:29:50 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Jul 28, 2005 3:29:50 AM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
Jul 28, 2005 3:29:50 AM org.apache.catalina.core.StandardContext start
SEVERE: Context startup failed due to previous errors

i have put in dd as follow

<listener>
<listener-class>com.MyContextListener</listener-class>
</listener>

and webpage is giving error page not found..
Mat Williams
Ranch Hand

Joined: Jul 20, 2005
Posts: 215
Hi Amit,

Try making the class public. Tomcat throws errors if it is not public.

HTH

Mat
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
done that...

as soon as i add listener tag in web.xml no file is accecible not even index.html through tomcat

why this happening ?
Narasimharao SV
Greenhorn

Joined: Feb 12, 2005
Posts: 9
put all your files .. so that we could try why that is happening..

SV
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
here are all the code...
http://www.coderanch.com/t/170042/java-Web-Component-SCWCD/certification/request-parameter-lost-sendredirect
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
guys please help me why its not working ?

i am eagerly waiting for your response..
thanx
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61218
    
  66

Check your logs carefully to be sure that your listener is not throwing an exception during its processing.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Antonio Giovanni
Ranch Hand

Joined: Jun 27, 2005
Posts: 85


Where did you put the above code in web.xml

In J2ee 1.3 specs,.. this should be before you mention
<Servlet>... stuff..
Correct me if i am wrong !!!

look here web.xml documentation
amit taneja
Ranch Hand

Joined: Mar 14, 2003
Posts: 810
this is not in case of j2ee 1.4

now problem got sovled..

one big tip for all : allways have public access modifier for listner classes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ServletContextListner not compiling