File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes related to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "related to servlet" Watch "related to servlet" New topic

related to servlet

harpreet singh sandhu

Joined: Oct 11, 2008
Posts: 2
i m harpreet here as software developer. my problem is related to servlet...i m trying to import own class in servlet class...exception fired like that can not fine symbol.i m sending the code.........
class abc
int i=10;
public int getd()
return i;
import abc;

import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class javaser extends HttpServlet
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
PrintWriter out = response.getWriter();

abc ob=new abc();
int k=ob.getd();
out.println("<h1>Servlet test</h1>");


F:\servlet>javac -classpath "servlet-api.jar"

F:\servlet>javac -classpath "servlet-api.jar" '.' expected
import abc;
^ ';' expected
import abc;
^ class, interface, or enum expected
3 errors
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33106

I don't think you can import classes in the default package since Java 1.4. You could put "abc" in a package. And then in import that. Some more details on imports.

Two other things:
1) "abc" is not in your classpath. You'll want something like:
javac -classpath ",;servlet-api.jar"
2) It's traditional to have classes start with an upperclass name. So you'd have Abc and Javaser. This isn't causing your problem - it's just a good habit to get into.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: related to servlet
jQuery in Action, 3rd edition