• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Questions regarding servlet context and methods  RSS feed

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


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.
 
Author and ninkuma
Marshal
Posts: 66797
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!