Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

regarding packages

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General (beginner)
 
Ranch Hand
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic