This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Are there any implicit objects available in servlets..? As for my view is concern there are no implicit objects in Servlet.. But in one of interview I faced recently, interviewer asked me this question and when I said there are no implicit objects available he was not agree with me.
Can any one throw some light on it..?
Cheers, Gaurav Daga [ August 13, 2007: Message edited by: Bear Bibeault ]
In JSP we have implicit objects that we do not need to bother about.Just use those.As JPS's would get converted to servlets and follow the servlets life cycle. Straight away you can start using those.All the JPS implicit objects map to some object from servlet specification.Like request means HTTPServletRequest and application means ServletContext. For better understanding you might want to have a look at the servlet java file translated by the container from the JSP.
In servlets you need to get references yourself.Use getServletContext method to get a reference to it , like this , others too.
I suppose the best answer would have been "Servlets are Java classes and there is nothing implicit in Java classes".
Though you may consider HttpServletRequest and HttpServletResponse as implicit object but its not 100% truth.
Those are not implicit at all. They are available only in the doGet and doPost methods, and there they are passed in explicitly as parameters.
Joined: Nov 29, 2005
Originally posted by Gaurav Daga: Though you may consider HttpServletRequest and HttpServletResponse as implicit object but its not 100% truth.
As Ulf mentioned ,those are not implicit objects.
I just wanted to say that for every implicit object in JSP , there is a equivalent object from servlet specification and you have to yourself get the reference to those objects before using those.
Like HTTPServletRequest reference you get from parameter of doXXX and you get reference to ServletContext from getServletContext method.And there are ways to get references to other objects like HTTPSession , servlet config etc .So in case of JSP just start using those implicit objects.If you want to know as how these implicit objects are made available to the JSP programer , then have a look at the servet that has been translated from a JPS file.
It could be that the interviewer was testing your confidence or looking to see if you were answering with a complete understanding of the material or, as many do, trying to get through the interview process with a bunch of memorized facts from interview cheat sheets.
Joined: Jun 19, 2006
It seems a solid point.
Anyways thnaks for your response.
Cheers, Gaurav Daga
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com