1)can we create object for servletContext?
2)ServletContext context= ---------getServletcontext------------->here nothing request not there ? why?something request.getServletcontext.
3)how to pass the query in the URL in servlets?
4)doGet & doPost & service difference? all the method separately working in the particular servlet.then wt is diff ?
5)how to overrride the doget& dopost method give basic example?
1) Not sure what you mean here. Create an object and put it into the ServletContext? That can be done with getServletContext().setAttribute("name", object). If you meant "how do I create a ServletContext object", you don't. The servlet container does that for you.
2) Again, not sure what you mean. The method getServletContext() is provided by GenericServlet, from which HttpServlet inherits. Check the API for GenericServlet.
3) That's not something YOU do. The servlet container maps incoming requests to the appropriate servlet, and provides the request parameters through the HttpServletRequest object (which is a parameter of the doGet() and doPost() methods).
4) doGet() is called for HTML GET requests, doPost() for HTML POST requests. A request can only have one of these so its always clear which servlet method will be called.
5) You override them like any other method, by providing an implementation for them.
In the future, please be sure to take the time to compose descriptive subjects for your posts. You will attract people who will can give you better and faster answers when your posts have good, descriptive subjects. For more information, please click this link ⇒ UseAMeaningfulSubjectLine.