File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes regarding packages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "regarding packages" Watch "regarding packages" New topic
Author

regarding packages

A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi all,

see the lines below.

here my question is javax.servlet.http.* is a subpackage of servlet package ,that mean what ever the classes in http package those are already available in servlet package.so what is the reason behind writing these two statements in servlet program.please give solution to me.

cheers,
babu.


Thanks,
www.Admakr.in
amod gole
Ranch Hand

Joined: Dec 07, 2005
Posts: 83
hi babu,

if you read carefully,Package concept then you will get an idea that
when you import any package then only classe(public)and interface of that package are get imported and not sub package
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60045
    
  65

Moved to Java in General (beginner)


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306

what is the reason behind writing these two statements in servlet program.please give solution to me.

import javax.servlet.*;
import javax.servlet.http.*;


As Amod mentioned above "sub packages" are not imported with import statement. That means to import a Class in the package javax.servlet.http, you need to specify the full package name. A partial package name is not enough.

Javax.servlet is a full package name when you consider classes and interfaces in javax.servlet package. For example javax.Servlet can import all interfaces and classes listed in the api
Note that Classes and interfaces under java.servlet.http cannot be imported by importing javax.servlet.*
Classes and interfaces listed under javax.servlet.http is listed in the api
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding packages
 
Similar Threads
DataSource class not found
Why do I get "Cannot forward after response has been committed"?
java.servlet.* cannot import, but javax.servlet.* ok???
RequestDispatcher problem
Head First Testing Init Paramters