Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding object creation of a ServletRequest interface  RSS feed

 
yekkala krishna
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Servlet Request is an interface in javax.servlet package.I found that web container is creating an object for this before calling service method of a servlet.

Is There any chances to me to find out how the object is going to create for that interface.

If i use req.getClass() its showing Exception saying that ClassNotFoundException.
 
Subhadip Chatterjee
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Krishna,
The basic idea is, the deployment descriptor alongwith web-container makes a servlet work, as Controller. Now, container always has it's implementations hidden, only few of the functionalities are available to resident servlet. So, as per my understanding, Container doesn't allow you to know, how it creates the instance of ServletRequest. Only when, the servlet starts-up in the container (servlet.init()), container binds an instance of Request to the Servlet object.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to see an actual implementation of HttpServletRequest, the complete source code for Tomcat can be downloaded. After you take a look at that you will be glad that servlet containers conceal all these details from you!

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!