• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Questions regarding servlet context and methods

Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
Ranch Hand
Posts: 214
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Posts: 67451
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

I have adjusted the title of this topic for you.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic