Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile Error: Class HelloServlet is public, should be declared in....

Status
Not open for further replies.

awolff01

Programmer
Jun 17, 2003
55
0
0
US
I am getting the following error:

HelloAsw.java:5: class HelloServlet is public, should be declared in a file naa
public class HelloServlet extends HttpServlet {


This is my code:

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

public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
&quot;<!DOCTYPE HTML PUBLIC \&quot;-//W3C//DTD HTML 4.0 &quot; +
&quot;Transitional//EN\&quot;>\n&quot;;
out.println(docType +
&quot;<HTML>\n&quot; +
&quot;<HEAD><TITLE>Hello</TITLE></HEAD>\n&quot; +
&quot;<BODY BGCOLOR=\&quot;#FDF5E6\&quot;>\n&quot; +
&quot;<H1>Hello World</H1>\n&quot; +
&quot;</BODY></HTML>&quot;);
}
}

What am I doing wrong?

 
Your class is called HelloServlet but you have saved the file as HelloAsw.java.

Save the file as HelloServlet.java and it will compile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top