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

Help Package Servlet Error

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
Hello I inherited a project from someone else. Their naming convention provides for all the servlets to be organized under a package.

When I remove the "package language" all I have is this:

On the line referring to the DiskFileItemFactory Item from above, the servlet has a red X beside it and it also says when you hover above that, "syntax error on tokens, delete these tokens".

I am not sure what I should do.

Can anyone shed some light for me?

Rob Spoor

Joined: Oct 27, 2005
Posts: 20276

Why did you remove the package structure? It's a very good practice to put every class inside a package. The only exceptions I make are small classes that I mostly use for quickly testing something and discard within an hour or so.

How To Ask Questions How To Answer Questions
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
I haven't exactly removed it, I just noticed that when I deleted that line there weren't as many errors. I can certainly put it back in but I will have lots more errors.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Most of the errors are going to be telling you about lines of code which should be inside a class. Which is every single line of code which you posted there. If you'll remember back to when you were learning basic Java, you should remember that a Java class starts with code looking something like this:

And yes, servlets are required to be in a package. But the package declaration isn't the source of your error messages.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
I agree. Here's the link:
subject: Help Package Servlet Error
It's not a secret anymore!