Noob Java Error

L

lucifer

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)
 
A

Andrew Thompson

lucifer said:
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).

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

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top