This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ServletContextListner not compiling

 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
Narasimharao SV
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1855
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit,

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

Regards,
Darya
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx...
Narasimharao Sandrapaty
darya


i don't know what happend to me


regards,
amit
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,

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

HTH

Mat
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
put all your files .. so that we could try why that is happening..

SV
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here are all the code...
http://www.coderanch.com/t/170042/java-Web-Component-SCWCD/certification/request-parameter-lost-sendredirect
 
amit taneja
Ranch Hand
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys please help me why its not working ?

i am eagerly waiting for your response..
thanx
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64700
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your logs carefully to be sure that your listener is not throwing an exception during its processing.
 
Antonio Giovanni
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic