• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why? newbie question

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why should I import
javax.servelet.* and javax.servelet.http.*
 
Mark Howard
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to if you don't want to
But you must if you want to make use of the Servlet API
ie. For the same reason you'd import any other package in a Java file.
 
Ivan Matmati
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
javax.servlet contains some base classes for servlets (like Servlet,Request, Response), javax.servlet.http contains classes specialized for handling http request (like HttpServlet that extends Servlet, HttpRequest..., HttpResponse...).
Good Bye.
 
Erik Pragt
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mark howard:

But you must if you want to make use of the Servlet API

Well, not entirely true, but it does save a lot of typing!
Without importing them, you would have to type (e.g.):

instead of

Good luck,
Erik
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!