Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Noob Java Error

Thread view: 
lucifer - 08 Jun 2007 10:21 GMT
Hi i m learning java n
i have written the following program but it does not compile

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Simple implements Filter
{
    public void doFilter(ServletRequest request, ServletResponse
response,    FilterChain chain)
   throws IOException, ServletException
 {

 }

 public void destroy()
 {

 }

 public void init(FilterConfig filterConfig)
 {

 }

}

when i come i get following errors
simple.java:4: class Simple is public, should be declared in a file
named Simple.java
public class Simple implements Filter
      ^
simple.java:2: package javax.servlet does not exist
import javax.servlet.*;
^
simple.java:3: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
simple.java:4: cannot find symbol
symbol: class Filter
public class Simple implements Filter
                              ^
simple.java:6: cannot find symbol
symbol  : class ServletRequest
location: class Simple
    public void doFilter(ServletRequest request, ServletResponse
response,
                         ^
simple.java:6: cannot find symbol
symbol  : class ServletResponse
location: class Simple
    public void doFilter(ServletRequest request, ServletResponse
response,
                                                 ^
simple.java:7: cannot find symbol
symbol  : class FilterChain
location: class Simple
   FilterChain chain)
   ^
simple.java:8: cannot find symbol
symbol  : class ServletException
location: class Simple
   throws IOException, ServletException
                       ^
simple.java:18: cannot find symbol
symbol  : class FilterConfig
location: class Simple
 public void init(FilterConfig filterConfig)
Andrew Thompson - 08 Jun 2007 10:45 GMT
>Hi i m learning java n

Please learn that word is 'and'.

>i have written the following program but it does not compile

Did you have a question?

In the meantime, I will make some comments..

1) A good group for those learning Java is comp.lang.java.help
2) Even on c.l.j.h., people will generally expect you to ask a
question, rather than have the reader simply guess what you want.
...

>import java.io.*;
>import javax.servlet.*;

3) Servlets are part of J2EE (or JEE - whatever Sun
is calling it at this instant).  J2EE is intended for
the server side, and before attempting it, it is best
to be proficient at J2SE (meant for the desktop
and core Java), at least to the point of solving basic
compilation errors, adding resources to the compilation
or runtime classpath, and naming files.  Not only is
J2EE built on the J2SE, but standard J2SE classes
are a lot easier to develop and debug than J2EE
classes - that might be cached by a servlet container,
and which present errors in a web page.  

I strongly advise you to forget J2EE for the moment,
and learn J2SE.

But to the first of the errors that you will need
to understand for either J2SE or J2EE..

> simple.java:4: class Simple is public, should be declared in a file
> named Simple.java

Java is case sensitive.  "simple.java"!="Simple.java"

This file *must* be called Simple.java, if the class is declared
public.  (Though it is generally a good idea to have *every*
class in a separate file of exactly the same name as the
class, whether it is public or not).

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.